Skip to content

Instantly share code, notes, and snippets.

View MishraKhushbu's full-sized avatar

KHUSHBU KUMARI MishraKhushbu

  • Bangalore
View GitHub Profile
http://www.techtrained.com/paging-procedure-lte/
@MishraKhushbu
MishraKhushbu / Why_dict_is_unordered.py
Created February 21, 2018 05:32
Python_Dictionary_21-Feb-2018
Since Python dictionary stores key value pairs, it uses hashing operations to store the values.
It is not necessary for the hash values to be in sorted order.
So when you print the dictionary the values are displayed on the basis of hash values and so python’s dictionary is un ordered.
If you want python dictionaries in sorted order, you can use sorted() function.
If want to use ordered dict in python we can use "ordereddict" module in short.
from _ordereddict import ordereddict
kio = ordereddict()
kvio = ordereddict(kvio=True)
# without relax unordered initalisation is not allowed
http://www.comlab.hut.fi/opetus/238/lecture7_RadioInterfaceProtcols.pdf
@MishraKhushbu
MishraKhushbu / Data_structure.py
Last active September 5, 2019 06:25
Data Structures/29Jan2018
http://res.cloudinary.com/dyd911kmh/image/upload/c_scale,f_auto,q_auto:best,w_700/v1512740202/Template_2_oxrskq.png
Data structures(list,tuple,strings,dictionary,sets)
===========================================================
Diff between tuple and sets
tuple:Immutable type,can contain dubplicates also defined in() whereas indexed
Sets:Mutable type,cannot contain dubplicates and defined in {}
empty set has to define like
@MishraKhushbu
MishraKhushbu / Exception_Handling.py
Created January 29, 2018 06:25
Exception handling 29 Jan 2018
What is Exception?
An exception is an error that happens during execution of a program. When that
error occurs, Python generate an exception that can be handled, which avoids your
program to crash.
Why use Exception?
Exceptions are convenient in many ways for handling errors and special conditions
in a program. When you think that you have a code which can produce an error then
you can use exception handling
Raising an exception breaks current code execution and returns the exception
back until it is handled.
@MishraKhushbu
MishraKhushbu / Access_Specifier.py
Last active January 11, 2018 12:33
Access_Specifiers_Python_11_Jan_2018
In Python access specifiers doesn't exist.Beacause it's considered as we all are adults here I mean if developerdoesn't want to aceess
a variable why will he.
In case if some variable needs to private it is initiated with '__'.
The main concept behind not having any of those logic is because, We used to have those access specifiers so
that out side classes will not be able to use the attribute of a class. But unless the developer will not try to
access a class within another class, They are not going to be used like that.
So default is public anyone can access any method anywhere.
But, You can privatize them in a different and more logical way. Using _ or __ .
__ can be used to define private attributes in a class. by default we define all variable names as words,
@MishraKhushbu
MishraKhushbu / Lambda_Function_9_Jan_2018.py
Last active January 9, 2018 12:38
Lambda_Function_9_Jan_2018
Mary had a little lambda,
as pure as snow
For every Program Mary wrote,
the lambda was all she needed to know
@MishraKhushbu
MishraKhushbu / Automate_Report.py
Last active January 29, 2018 06:30
Karthik task
#! /usr/bin/python
#Opening the file
f0 = open("out.txt","rw+") #File containing the original testing report.
f1 = open("new.txt","rw+") #File containg the report in string format
f2 = open("new3.txt","rw+")#File containing the required fields in string format
f3 = open("book2.csv","w+")#csv file with the value for keys
#function to remove whitespaces from file out.txt and writing it in new.txt
@MishraKhushbu
MishraKhushbu / List Comprehension 6 dec 2017
Last active January 8, 2018 11:37
List Comprehension 6 dec 2017
Basic Examples:
1.{ x^2: x is a natural number less than 10 }
[x*2 for x in range(0,10)]
2.{ x: x is a whole number less than 20, x is even }
[x for x in range(0,20) if x%2 == 0]
3.{ x: x is an alphabet in word ‘MATHEMATICS’, x is a vowel }
[x for x in "MATHEMATICS" x not in "AEIOU"]
=======================================================================================
The same gets implemented in a simple LC construct in a single line as:
[ output_expression() for(set of values to iterate) if(conditional filtering) ]
@MishraKhushbu
MishraKhushbu / RANGE_XRANGE.PY
Created November 24, 2017 10:19
24/nov/2017 Range/xrange
Python2 --Range
1.It produces a list for itertions.
For x in range(3):
print x
O/p:
0
1
2
y = range(5)