Learn With Tawhid
Learn With Tawhid
'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or',
'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']
Variables- Number,string…. Etc.
Keywords of Library Key in python cannot be Variables Name.
Data Type-
Number, Sequence (String- x=”Hello”, List- x=[“ ”,” ”], Tuple - x=(“ ”,” ”)),
Boolean(True, False),Dictionary(Key: Value(
cardict={ x="Hello World"
print(x)
“name”=”Jamal”, “year”=”2008”
print(type(x)) Preview
} b=10
)) print(b) Hello World
Declaring Variables print(type(b)) <class 'str'>
10
S=”Hello there.” y=[1,2,3,5] <class 'int'>
Print(s) print(y) [1, 2, 3, 5]
<class 'list'>
Print(type(s)) print(type(y)) <class 'tuple'>
m=(1,2,3,5)
print(type(m))
del x
print(x) Preview
output: Name Error Enter the Value you like: 100
200.25
User Input
s=int(input(“Enter a Number:” ))
print(s+100)
We Should fix type of data
Int( ), float( ), str( )
Comment in Python by Starting Line with # or """ Writing something here """
Class 03
Class 06 a=10
b=2
Nested If Statement: if(a>5 and a<20):
Syntax: print("both conditions are true")
if(b<30 or b>50):
If test_Expression1:
print("one of the conditions is true")
If test_Expression2: x=5
Body of if print(x>3 and x<10)
Else: '''not logical operators using below'''
Body of else print(not(x>3 and x<10))
Else:
Body of else both conditions are true
break Loop
Break Loop
count=0
while count<5: Hello 1
count+=1 Hello 2
if count==3:
Break
print("Hello",count)
outer=1 1,1
while outer <=3:
inner=1 1,2
while inner <=4:
1,3
print(outer,",",inner) inner loop terminates
inner +=1
print("inner loop 2,1
terminates") 2,2
outer +=1
print("outer Loop 2,3
Terminates") inner loop terminates
outer Loop Terminates
Class 09
a=[10,9,11,100,51,64,99,82] 100
largest=5
for i in a:
if i > largest:
largest=i
print(largest)
Class 10