Professional Documents
Culture Documents
Python Summary
Python Summary
Python Summary
_
A-Z A-Z a-z 0-9 _
a-z
Legal Illegal
Myname 2myname
my_name my-name
_myname my name
my_name2 my.name
Comment
a=b=c=10 a,b,c=2,3,6
a = 10 ( int – integer )
a → 10 a→2 b = 2.5 ( float )
b → 10 b→3 c = ‘amal’ ( str – String )
c → 10 c→6
Break
a=1 output
while a<6:
print(a)
if a==3:
break
a=a+1
Continue
output
While True i=0
While loop For Loop
while i<6:
i=i+1
if i==3:
output continue
print(i)
Never Ends
Age.insert(2,10)
(adding a new elemnt [12,14,10,21,8,60]
for 2nd position)
Age.remove(10) [12,14,21,8,60]
(removing from the list)
L1=[1,3,4,3,6] L1.count(3) 2
(How many times)
String
A=[‘Hi how are’] A.Find(‘how’) 3 (index)
‘A’+’B’ → ‘AB’
N=[4,6,1,3,9,8] N.Sort()
‘A’+’ ‘+’B’ → ‘A B’ (ascending oder)
[1,3,4,6,8,9]
N1=[1,2,3]
A=‘Nimal’ N1.extend(N2) [1,2,3,4,5,6]
N2=[4,5,6] (like concatenation)
len(a)
5
[1,2]+[3,4] → [1,2,3,4] L=[1,2,3]
‘AB’*2 3 in L → True
‘ABAB’
Function Local Variable Global Variable
With parameter
XYZ ABC
XYZ