1st rule
aiquest = 110 _studernt = 'ai based' # 2nd rule django2 = "web development" print(django2)
- kind of variable you can use
1 . camel case
āĻā§āĻ āĻĨā§āĻā§ āĻŦāĻĄāĻŧ
helloWorld = 'hello world'
2 . pascal case
āϤāĻžāϰ āĻĒā§āϰāĻĨāĻŽ āĻ āĻā§āώāϰ āĻŦāĻĄāĻŧ
HelloWorld = 'hello world'
- snake case
āĻāĻāĻžāύ⧠āĻāĻāĻāĻž āĻļāĻŦā§āĻĻā§āϰ āĻĒāϰ⧠āĻĄā§āϝāĻžāĻļ āĻĨāĻžāĻā§ āĨ¤
hello_world = 'hello world'
āĻā§āĻāĻžāύ⧠id āĻĻāĻŋāϝāĻŧā§ āϞā§āĻā§āĻļāύ āĻā§āĻ āĻāϰāĻž āĻšāϝāĻŧā§āĻā§ āĨ¤ a, b , c āĻāĻĻā§āϰ āϞā§āĻā§āĻļāύ āϏā§āĻāĻŽ āĨ¤
varible āĻā§āϞ⧠āĻāĻ āĻāĻžāϝāĻŧāĻāĻžāϝāĻŧ āϏā§āĻāĻŽ āĻšāĻā§āĻā§ āĨ¤
a = b = c = 34 # ekhane location same print(id(a)) # memory location dekte pari print(id(b)) # id mane location print(id(c))
z, u , m āĻāĻāĻžāύ⧠āĻŽā§āĻŽā§āϰāĻŋ āϞā§āĻā§āĻļāύ āĻāĻŋāύā§āύ āĨ¤
z , u, m = 10 , 20 , 39 # ekhane location different print(id(z)) print(id(u)) print(m)
āĻāĻāĻžāύ⧠āĻĄāĻŋāĻĢāϞā§āĻ āϏā§āĻā§āϰāĻŋāĻ āύāĻŋāĻŦā§ āĨ¤
āϏā§āϤāĻžāϰāĻžāĻ āϝāĻĻāĻŋ āĻāĻŽāϰāĻž āĻāύāĻĢā§āĻ āĻšāĻŋāϏā§āĻŦā§ āϏāĻāĻā§āϝāĻž āĻĻāĻŋāĻ āϤāĻžāĻšāϞ⧠āĻ āĨ¤
z = input('enter 1st number') # string input value string hbe bydefault string y = input('enter 2nd number') # string input value string hbe bydefault string sum = z + y print(sum) print(id(z))
āϝāĻĻāĻŋ āĻāĻŽāϰāĻž āĻāύāĻĢā§āĻ āĻšāĻŋāϏā§āĻŦā§ āĻāύāĻāĻŋāĻāĻžāϰ āύāĻŋāϤ⧠āĻāĻžāĻ , āϤāĻžāĻšāϞā§
# input for int ================= z = int(input('enter 1st number')) # string input value string hbe bydefault string print(id(z)) y = int(input('enter 2nd number')) # string input value string hbe bydefault string sum = z + y print(sum)
print āĻĢāĻžāĻāĻļāύ ⧍āĻāĻž āĻāϰā§āĻāĻŽā§āύā§āĻ āύāĻŋāĻŦā§ āĨ¤
- sep // āĻāĻāĻž āĻāϞāĻžāĻĻāĻž āĻāϰāĻŦā§
- end // āĻāĻāĻž
- values
- file
- flash
print('hello world') print("hello" , 'world' , sep="&" ,end="]") # hello&world]
import sys; s = 'welcome to python with django' # āĻāĻāĻžāύ⧠āĻā§āύ āĻāύāĻĄā§āĻā§āϏ⧠āĻāĻŋ āĻāĻā§ , āĻāĻāĻž āĻā§āĻ āĻāϰāĻž print(s[0:3]) # wel print(s[0:3333]) # upper case print(s.upper()) # WELCOME TO PYTHON... # lower case print(s.lower()) # welcome... # white space remove # āϝā§āĻŽāύ : s = ' welcome to python with django' # āĻāĻāĻžāύ⧠capital āĻā§ small āĻāϰ⧠āĻĻāĻŋāĻŦā§ āĨ¤ print(s.capitalize()) # # white space remove print(s.strip()) # repalace string print(s.replace('o' , 'a')) # # split string print(s.split()) # 'welcome' , 'to' , 'python' print(s.split()[0]) # welcome āĻŽāĻžāύ⧠āĻĒā§āϰāĻĨāĻŽ āĻļāĻŦā§āĻĻāĻāĻž āϰāĻŋāϰā§āĻāĻžāύ āĻāϰāĻŦā§ āĨ¤ # stirng Concatination v = '23' print(s+ "" + v) # welcome to ... '23' # counting print(s.count("o")) # 3 ta o ache # lenth print(len(s)) # āĻāĻ āĻāϤ āĻŦāĻžāĻāĻ āϏāĻžāĻāĻ āĻāĻāĻž āĻĒā§āϰāĻŋāύā§āĻ āĻāϰāĻŦā§ āĻŽāĻžāύ⧠āĻā§āĻ āĻā§āϝāϰāĻŋāϝāĻŧā§āĻŦāϞ āĻāϤ āϏāĻžāĻāĻ āĻĻāĻāϞ āĻāĻŦā§ āĻāĻā§ āĨ¤ print(sys.getsizeof(s)) # index , find āĻāĻ āĻŽā§āĻĨāĻĄ āĻĻā§āĻāĻāĻž āĻāύāĻĄā§āĻā§āϏ āύāĻžāĻŽā§āĻŦāĻžāϰ āϰāĻŋāϰā§āĻāĻžāύ āĻāϰāĻŦā§ āĨ¤ # āϝāĻĻāĻŋ āĻāĻžāϞ⧠āύāĻž āĻĨāĻžāĻā§ index āĻ āĻāϰāϰ find āĻ -1 return āĻāϰāĻŦā§ āĨ¤ print(s.index('w' , 0 , 8)) print(s.find('y' , 4 , 8)) # āĻāĻāĻž āϝā§āĻā§āϞ⧠āĻŦāĻĄāĻŧ āĻšāĻžāϤā§āϰ āĻāĻā§ āĻāĻāĻž āĻā§āĻ āĻšāĻžāϤā§āϰ , āĻā§āĻ āĻĨāĻžāĻāϞ⧠āĻŦāĻĄāĻŧ āĨ¤ print(s.swapcase()) # āĻāĻāĻž āĻĒā§āϰāϤā§āϝā§āĻāĻāĻž āĻļāĻŦā§āĻĻā§āϰ āĻĒā§āϰāĻĨāĻŽ āĻ āĻā§āώāϰ āĻŦāĻĄāĻŧ āĻšāĻžāϤā§āϰ āĻšāĻŦā§ āĨ¤ print(s.title()) # āĻāĻā§āϞ⧠āĻŦāĻĄāĻŧ āĻšāĻžāϤā§āϰ āĻāĻŋāύāĻž āĻāĻŦāĻ āĻā§āĻ āĻšāĻžāϤā§āϰ āĻāĻŋāύāĻž āĻā§āĻ āĻāϰāϰ⧠āĨ¤ print(s.isupper()) print(s.islower()) # āĻāĻāĻžāύ⧠⧧ā§Ļā§Ļ āĻāϰ āĻĒāϰ⧠welcome to ... āĻāĻāĻžāĻŦā§ āĻāϏāĻŦā§ āĨ¤ print(s.center(100)) # āϏā§āĻā§āϰāĻŋāĻ āĻĢāϰāĻŽā§āĻ # āĻāĻāĻžāύ⧠1000 {} āĻāϰ āĻŽāϧā§āϝ⧠āĻŦāϏ⧠āϝāĻžāĻŦā§ āĨ¤ x = 1000 print('this si {} taka'.format(x)) # this is 1000 taka print(s.encode()) # āĻāĻāĻžāύ⧠byte āĻāĻāĻžāϰ⧠āĻāϏāĻŦā§ āĨ¤ print(type(s.encode()))
- 3 types of Numaric data typd
- Integer
- Float
- Complex
a = 33 b = -88 c = 88888800000000000000000000000088888888888 print(type(a)) print(type(b)) print(type(c))
d = 89.9 e = -88.8 f = 888888888888888888888888888888888888888888888888888888888888888.888 print(type(d)) print(type(e)) print(type(f))
# complex ekhane kivabe china jay g = 4+4j h = 4+8j print(type(g)) print(type(h))
āĻāύā§āĻāĻŋāĻāĻžāϰ āĻĨā§āĻā§ āĻĢā§āϞā§āĻ float to interger āĻāύāϰā§āĻāĻžāĻ āĻšāϝāĻŧ āĨ¤
z = 30 u = 33.44 m = 8j # j chara r hbe na num_str = "10" num_int = int(num_str) # Converts string to integer print(num_int) # Output: 10 num_float = 3.14 num_int = int(num_float) # Converts float to integer print(num_int) # Output: 3 num_str = "10" num_int = complex(num_str) # Converts string to complex print(num_int) # Output: 10+0j num_float = 3.14 num_int = complex(num_float) # Converts float to complex print(num_int) # Output: (3.14+0j) #int to float l = float(z) print("int to float" , type(l)) # int to complex o = complex(z) print("int to float" , type(o)) # float to complex r = complex(u) print('float to complex', type(r)) #float to int q = int(u) print('float to int', q) #Boolean print(type(True)) #<class 'bool'> print(type(False)) y = 90<20 print(type(y)) #<class 'bool'>
#dictionary # {} set , dictionary āĻšāϞ second bracket āĻļā§āϰā§āϤ⧠āĻāĻŦāĻ āĻļā§āώ⧠āĻšāϝāĻŧ āĨ¤ # āϤāĻŦā§ python āĻ dictionary āĻāĻŋ āĻāĻŦāĻ āĻāĻžāϞ⧠java āϤ⧠map āĻāϰ āĻŽāϤ⧠āĨ¤ firstdict = { "name" : 'Arif', "id" : 222, "year" : 2333 } print(firstdict) # {'name': 'Arif', 'id': 222, 'year': 2333} print(type(firstdict)) # <class 'dict'>
# āϞāĻŋāϏā§āĻā§ āĻ āύā§āĻ āϰāĻāĻŽā§āϰ āĻĄāĻžāĻāĻž āĻāĻžāĻāĻĒ āĻĨāĻžāĻā§ āĨ¤ # āĻāĻŦāĻ āĻļā§āϰā§āϤ⧠, āĻļā§āώ⧠third bracket āĻĨāĻžāĻāĻŦā§ āĨ¤ firtlist = ['lenebo' , 33 , '83'] print(firtlist) # ['lenebo' , 33 , 83] print(type(firtlist)) # <class 'list'>
remove and pop āĻāϰ āĻŽāϧā§āϝ⧠āĻĒāĻžāĻĨā§āϝāϰā§āĻ āĻšāĻā§āĻā§ remove parameter āύāĻŋāĻŦā§ āĻāĻāĻāĻž item . āϝāĻĻāĻŋ āĻ itex āύāĻž āĻĨāĻžāĻā§ exception āĻĻāĻŋāĻŦā§ āĨ¤
pop āĻšāĻā§āĻā§ index āĻšāĻŋāϏā§āĻŦā§ āύāĻŋāĻŦā§ āϝāĻĻāĻŋ āĻ āĻāύāĻĄā§āĻā§āϏ āύāĻž āĻĨāĻžāĻā§ -ā§§ āϰāĻŋāĻāĻžāύ āĻāϰāĻŦā§
delete method āĻāύāĻĄā§āĻā§āϏ āĻāĻāĻžāϰ⧠āĻĄāĻŋāϞāĻŋāĻ āĻšāϝāĻŧ āĨ¤ āϝāĻĻāĻŋ āĻāύāĻĄā§āĻā§āϏ āύāĻž āĻĨāĻžāĻā§ āϤāĻžāĻšāϞ⧠exception āĻĻāĻŋāĻŦā§ āĨ¤ āĻāĻŦāĻžāϰ āϏāĻŽā§āĻĒā§āĻŖ āĻĄāĻŋāϞāĻŋāĻ āĻšāϝāĻŧ āĨ¤
course = ['Math', 'Science', 'History', 'English', 'Geography'] print(len(course)) #access item print('list item is ' , course[4]) # output Geography āĻāĻāĻž āĻāĻŋāϰ⧠āĻĨā§āĻā§ āĻļā§āϰ⧠āĻšāϝāĻŧ āĨ¤ print('list item' , course[-4]) # output Science āĻāĻāĻž āĻāϞā§āĻā§ āĻĻāĻŋāĻ āĻĨā§āĻā§ query āĻāϰ⧠# Range # āĻāĻāĻž āĻļā§āϰ⧠āĻāĻŦāĻ āĻļā§āώ āĻĨā§āĻā§ āϏāĻžāϰā§āĻ āĻāϰāĻŦā§ āĨ¤ print("Range:", course[2:5]) # Output: ['History', 'English', 'Geography'] # āĻāĻāĻž āĻļā§āώ āĻĨā§āĻā§ search āĻāϰāĻŦā§ print("Range:", course[:5]) # Output: ['Math', 'Science', 'History', 'English', 'Geography'] # āĻāĻāĻžāύ⧠āĻāĻā§ āĻĒāĻžāĻāĻāĻž item āĨ¤ āϏā§āϤāĻžāϰāĻžāĻ āĻāĻāĻžāύ⧠āĻļā§āϰā§āϤ⧠āĻĒāĻžāĻāĻāĻž āĻāϰ āĻĒāϰ āϏāĻžāĻ āĻāϰāϞ⧠āĻĢāĻžāĻāĻž array āĻāϏāĻŦā§ āĨ¤ print("Range:", course[5:]) # Output: [] # Negative range # āĻāĻāĻž āĻāĻŋāĻ āĻāϞā§āĻā§ āĻšāĻŦā§ āĨ¤ print("Range:", course[-2:]) # Output: ['English', 'Geography'] print("Range:", course[:-2]) # Output: ['Math', 'Science', 'History'] # Item value change course[1] = 40 # āĻāĻāĻžāύ⧠āĻā§āύā§āĻ āĻāϰāĻž āĻšāϝāĻŧā§āĻā§ āĨ¤ print('New list:', course) # Output: ['Math', 40, 'History', 'English', 'Geography'] # Insert method # āĻāĻāĻžāύ⧠āĻā§āύ index āĻ insert āĻāϰāϤ⧠āĻāĻžāύ āĨ¤ course.insert(0, "aiQuest") print('New inserted list:', course) # Output: ['aiQuest', 'Math', 40, 'History', 'English', 'Geography'] # Append method # append āĻšāĻā§āĻā§ āĻāĻāĻĻāĻŽ āĻļā§āώ⧠append korbe course.append("study marts") print('Append:', course) # Output: ['aiQuest', 'Math', 40, 'History', 'English', 'Geography', 'study marts'] # Remove method course.remove('Math') print('Remove:', course) # Output: ['aiQuest', 40, 'History', 'English', 'Geography', 'study marts'] # Pop method course.pop(2) print('Pop:', course) # Output: ['aiQuest', 40, 'English', 'Geography', 'study marts'] # Del keyword del course[2] print('Del:', course) # Output: ['aiQuest', 40, 'Geography', 'study marts'] # Sort method alphabetic = ['python', 'django', 'ML'] alphabetic.sort() print('Sorted:', alphabetic) # Output: ['ML', 'django', 'python']
# āϞāĻŋāϏā§āĻā§ āĻ āύā§āĻ āϰāĻāĻŽā§āϰ āĻĄāĻžāĻāĻž āĻāĻžāĻāĻĒ āĻĨāĻžāĻā§ āĨ¤ # āĻāĻŦāĻ āĻļā§āϰā§āϤ⧠, āĻļā§āώ⧠second bracket āĻĨāĻžāĻāĻŦā§ āĨ¤ firstset = { 'aiquest' , 383, 38.8 , 88, True } print(firstset) # {True, 38.8, 88, 'aiquest', 383} print(type(firstset)) # set output --- <class 'dict'>
# āĻāĻāĻžāύ⧠āĻāύā§āĻāĻā§āϞ⧠āĻĄāĻžāĻāĻž āĻāĻžāĻāĻĒ āĻĨāĻžāĻā§ # āĻāĻŦāĻ āĻļā§āϰā§āϤ⧠āĻāĻŦāĻ āĻļā§āώ⧠first bracket āĻĨāĻžāĻā§ āĨ¤ firsttuple = ('ai' , 33, "idid" , 8 , True ) print(firsttuple) # ('ai', 33, 'idid', 8, True) print(type(firsttuple)) # <class 'tuple'>
āĻāĻāĻž āĻŦāĻžāĻāύāĻžāϰāĻŋ āύāĻŋāϝāĻŧā§ āĻāĻžāĻ āĻāϰāĻžā§ āĨ¤ āĻĒāϰ⧠āĻāϞā§āĻāύāĻž āĻāϰāĻž āĻšāĻŦā§ āĨ¤
āĻāĻāĻž āĻā§āĻŦāĻŋāϞ āĻāĻāĻžāϰ⧠āĻāĻāĻāĻĒā§āĻ āĻāϏ⧠āĨ¤ āĻāĻāĻž āύāĻŋāϝāĻŧā§ āĻĒāϰ⧠āĻāϞā§āĻāύāĻž āĻāϰāĻž āĻšāĻŦā§ āĨ¤
division āĻŽāϧā§āϝ⧠āϝāĻĻāĻŋ āĻāĻžāĻāĻļā§āώ āύāĻž āĻĨāĻžāĻāϞ⧠āĻĒā§āϰā§āĻŖ āϏāĻāĻā§āϝāĻž āĻāϰ āĻĨāĻžāĻāϞ⧠āϤāĻžāĻšāϞ⧠āĻĒāϝāĻŧā§āύā§āĻ āĻāĻāĻžāϰ⧠āĻĻāĻŋāĻŦā§ āĨ¤ floor āĻšāĻā§āĻā§ āĻāĻžāĻāĻļā§āώ āĻĨāĻžāĻā§āĻ āĻŦāĻž āύāĻž āĻĨāĻžāĻā§āĻ āĻĒā§āϰā§āĻŖ āϏāĻāĻā§āϝāĻž āĻĻāĻŋāĻŦā§ āĨ¤
āĻā§āύ āϏāĻāĻā§āϝāĻžāϝāĻŧ āϝāĻĻāĻŋ āĻā§āύ āĻĻāĻļāĻŽāĻŋāĻ āĻŦāĻž āĻāĻā§āύāĻžāĻāĻļ āύāĻž āĻĨāĻžāĻā§ āϤāĻžāĻšāϞ⧠āϏā§āĻāĻŋ āĻĒā§āϰā§āĻŖ āϏāĻāĻā§āϝāĻžāĨ¤
x = 12, y = 4 āĻŽāĻžāύā§
12 * 12 * 12 * 12 āĻāĻāĻžāύ⧠12 4 āĻŦāĻžāϰ āĨ¤
x = 5 y = 2 #Addition print("Add ", x + y); # 7 # Subtraction print('sub', x -y) # output : 3 # mutiple print('multiply' , x * y) # output : 10 # division print('div' , x / y) # output : 2.5 # modulus print("modulus" , x % y) # output : 1 # exponentiation print("exponentiation", x**y) # output : 25 # floor division print('floor division' , x//y) # output : 2
āĻāĻāĻžāύ⧠āĻāĻāĻāĻž āĻā§āϝāϞ⧠āĻāϰā§āĻāĻāĻž āĻā§āϝāĻžāϞ⧠āĻāϰ āĻŽāϧā§āϝ⧠āĻāϏāĻžāĻāύ āĻāϰāĻž āĨ¤
x = 5 y = 3 x =y print('assign' , x ) # output 3 x += y print('add and Assgainment' , x) # age 3 chilo , ekhon 3 + 3 = 6 x -= y print("sub and assign" , x) x *= y print("multiply and assign" , x) x %= y print("moduls and assign" , x)
- & : bitwise and
- | : bitwise Or
- ^ : bitwise Xor
- ~ : bitwise complement operator
- << : left shift operator
- : >> : right shift operator
x = 12 y = 13 print('complement operator', ~x) #~ reverse kore ~1=0 , ~0=1 , output = -13 print('bitwise and ' , x&y) # output 12 print("bitwise or", x|y) # output 13 print("bitwise xor" , x^y) # output 1 a = 12 b = 2 print('left shift ', a<<b) #output 48 print('right shift ', a>>b) # output 3
< : less than
.> : Greter than
<= : less than or equal to
.>= : Greater than or equal to
== : Equal to
!= : Not Equal to
x = 5 y = 2 print("less than ", x<y) # output False print("Grater than" , x>y) # output True print('Less than or eqal to' , x<=y) # output False print('Greater than or eqal to ', x>=y) # output True print("Equal to", x==y) # output False print("Not equal to ", x!=y) # output True
x = 12 y = 12 print(x is y) # True print(x is not y) # false
x = 5 y = 2 print(x is y) # True print(x is not y) # false print("Equal to", x==y) # output False print("Not equal to ", x!=y) # output True
x = 14 y = 3 print(x>y and x<y) # false , āĻāĻāĻžāύ⧠āĻĻā§āĻāĻž āϏāϤā§āϝ āĻšāϤ⧠āĻšāĻŦā§ print(x>y or x<y) # true , āĻāĻāĻžāύ⧠āĻāĻāĻāĻž āϏāϤā§āϝ āĻāĻŦāĻ āĻŽāĻŋāĻĨā§āϝāĻž āĻšāϤ⧠āĻšāĻŦā§ print(not(x<y and x>y)) # true , āĻāĻāĻž āĻ āĻŋāĻ āĻāϞā§āĻā§
x = ['python', 'django'] print("python" in x) # true print("pythons" not in x) # true
javaScript , java āϤ⧠second bracket āĻāĻā§ āĨ¤ āĻāĻŋāύā§āϤ python āĻ āĻļā§āϧ⧠āĻā§āϞāύ āĻāĻā§ āĨ¤
motu = 100 patlu = 40 jhatka = 32 if(motu>patlu and motu<jhatka) : print('this is if')# ekhane identaion check korte hbe elif(patlu>motu or patlu>jhatka): print("this is else") else: print("this is else")
for loop āϏāĻāĻā§āϝāĻž āĻāĻŋāϤā§āϤāĻŋāϤ⧠āĻāĻŦāĻ āϞāĻŋāώā§āĻā§ āϞā§āĻĒ āĻāϰāĻž āĻšāϝāĻŧā§ āĨ¤
javaScript , java āϤ⧠second bracket āĻāĻā§ āĨ¤ āĻāĻŋāύā§āϤ python āĻ āĻļā§āϧ⧠āĻā§āϞāύ āĻāĻā§ āĨ¤
# āĻāĻāĻž list fruits = ['banana', 'apple', 'orange'] for fruit in fruits: if fruit == 'apple': continue # āĻāĻāĻž apple āĻāϰ āϏāĻžāĻĨā§ āĻŽāĻŋāϞāϞ⧠āϏā§āĻāĻŋāĻĒ āĻāϰāĻŦā§ āĨ¤ print("Fruits name" ,fruit) print('fruit len' , len(fruit)) # āĻāĻāĻž range # range(stop)============================= for i in range(10): print("this is my range") # 0 theke 9 print korbe # range(start , end) for i in range(50, 60): # 50 theke 59 porjonto print korbe because ekhane 60 border hisabe kaj kore print("this is my range" , i) # range(start , end , # range(start, stop, step) for i in range(2 , 100 , 3): print("this is ")
āĻ āύāĻŦāϰāϤ āĻā§āϰāϤ⧠āĻĨāĻžāĻāĻŦā§ āĨ¤
condition āĻĻāĻŋāϤ⧠āĻšāĻŦā§ āĨ¤
javaScript , java āϤ⧠second bracket āĻāĻā§ āĨ¤ āĻāĻŋāύā§āϤ python āĻ āĻļā§āϧ⧠āĻā§āϞāύ āĻāĻā§ āĨ¤
value increase āĻāϰāĻžāϰ āĻĒāĻĨ āĻŦāϞ⧠āĻĻāĻŋāϤ⧠āĻšāĻŦā§ āĨ¤
i = 4 while i<10: print(i) i+=1 # eta dite hbe while i<1 : i+=1 if i == 5 : # ekhane continue print(i) else: print(i)