Professional Documents
Culture Documents
Python Notes
Python Notes
Open the command prompt on desktop then the following command lines can be used for different uses
like
In the jupyter notebook click on cell-- run cell : to run the code
And shift+enter gives you a new cell/ runs the current cell code and gives new cell
PYTHON DATATYPES:
Type example
name
integer Int 2 300 40
Floating point float 25.4 200.0
Strings str Ordered sequence of characters: “hello”
‘hello’ “2000” ‘2000’ etc
Lists List Ordered sequence of objects:
[10,”hello”,200.3]
Dictionaries Dict Unordered key:value pairs:
{“mykey”:”value”,”name”:”frankie”}
Tuples Tup Ordered immutable sequence of objects:
(10,”hello”,200.4)
Sets Set Unordered collection of unique objects:
{“q”,”b”}
Boolean bool logical value indicating True or False
Operation codes:
Addition: 2+1
Subtraction:2-1
Multiplication: 2*3
Division:2/3
3//2 – it gives only the quotient value or u can say it doesnot round up the value of3/2 i.e 1.5 and gives
the final value as only 1
When brackets are not given to the code where more than one arithemetic operation takes place it
follows BODMAS
Variable assignments:
Shouldnot start with number,can not use any other special characters
Python uses dynamic typing I.e a variable can be assigned to different data types in a code
Eg: my_dog=1
my_dog=“Sammy”
this is allowed in python but not in other languages where it leads to error
eg:
code:
Code2:
a=5
a=a+a // this line implies the previous value of a is added up twice and assigned the new value to a//
type(a)
Eg:
Character: h e l l o
Index: 01234
Reverse index: 0 -4 -3 -2 -1
Every character has a index, generally start with 0. Spacing doesnot counts
Indexing action use [] and a number index to indicate positions of what you wish to grab.
Note: when a string is given print command the output doesnot show the double quotes or single
quotes but when executing the code u don’t give print command but just run a string code the output
will be seen in the quotes given, u can see the example the jupyter notebook and the other scenarios
are also seen in it
\n -new line
string properties:
Immutability: u cannot change a string, like if a string is given name=sam and now u want to
change it to pam by giving name[0]=’p’ this gives error. Rather we can change it by merging two
strings. Remember u cannot add number to string. See the example in notebook.
00123654789p0ol.,m bx