Notes and some extra tips,tricks ,points ,suggestion etc
VERSION == PY --VERSION
"," inbetween variables gets printed as single space
print(sep="abj") // single space will be replaced by abj
print(end="axn") // after printing axn will be added in the end without any space inbetween
escape sequence /t (tab space) /n (new line)
module installation == py -m pip install <<module name>>
comments - # , """ """
By default the input is taken as string
reserved words == help("keywords")
alt+p previous command
In shell if we directly type something within " " then it as whole will be displayed .(known as display)
translator -- interpreter(line by line)=shell/interactive mode , compiler(whole program)=Script mode
GUI Programming uses tkinter library
"{index}".format(variable) will work same as variable in between text without multiple commas and inverted commas.
import random
x=5,y=5 then id(x)==id(y)
Data type : Conplex:
x=complex(2+5j)
x=2+5j # print(x.real,x.imag)
alternate to .format == f before" without space or , and {variablename}
bool(0)==false , else everything true
""" docstring """
extensions .py .pyw
math.floor(75/12)==6
"k"+"t"==kt concatenation (no spaces)
replication "kt"*2 == ktkt (no spaces)
not equal !=, <>(doesn't work)
string comparison is base don ascii value and is from left to right
eval("15+12")==27(int)
py help("modules")
sequel flow==construct
range(start,stop,step)
str[index] interpreter == quotes will come
display method give answers in single quotes
"abc"*7=== 7*"abc"
7*[1,2,3],7*(1,2,3) is valid
7*{1:'b'} is invalid (keys are immutable,values are mutable)
immutable-string,tuple,Frozenset,numeric... (we can't change the value in place)
When using comparison operators, python int and float are comparable without throwing any error, they can be become equal(if no value after decimal point).
Walrus Operator
The Walrus Operator allows assignment of variables within an expression while returning the value of the variable
Example:
print(my_var:="Hello World!")
# 'Hello world!'
.
Comments
Post a Comment
For any queries or suggestions
Comment Here