0% found this document useful (0 votes)
20 views5 pages

Learn With Tawhid

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views5 pages

Learn With Tawhid

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Class 01 ['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif',

'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))

Class 02 """name xb is not defined"""


Deleting Variable x=int(input("Enter the Value you
like:" ))
x=”Python Second Class” print(x+100.25)

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

Study from Note


x=5 8
x+=3 False
print(x)
b=10 True
c=["10","15"] True
y="Hello World"
print(x is y) 18
print(b is not c)
print("10" in c)
print(x+b)
Class 04
'''when true''' a is greater than 10
a=15
if a>10: block of it
print("a is greater than
10") Code Ended
print("block of it")
print("Code Ended") another condition
print("another condition")
'''When false''' Code Ended for another
b=8
if b>10: foo 42 bar
print("b is greater than
10") foo/42/bar
print("block of it")
print("Code Ended for another") foo...42...bar
print("foo",42,"bar")
print("foo",42,"bar",sep="/") foo , 42 , bar
print("foo",42,"bar",sep="...")
print("foo",end=" , ")
print(42,end=" , ")
print("bar")

*Study from Note


Class 05
'''if statement'''
a=16
if (a>10):
print("a is greater
than 10") a is greater than 10
print("code ended")
code ended
'''if else statement'''
x=int(input("Number you Number you want:100
want:" ))
'''making Input''' Even Number
if(x%2==0):
print("Even Number")
else:
print("Odd Number")

a=int(input("input the Number:"))


mark= int(input("Enter your
b=int(input("input another Number:"))
Number: ")) if(a>b):
input the Number:10
if(mark>=50): Enter your
input another print("a is greater than b")
Number: 40
print("pass") Number:9 elif(a<b):
else: fail a is greater than b print("a is less than b")
print("fail") else:
print("a and b are equal")
a=11 a is less than b
b=45
c=["BMW","Audi"] d is found in c
d="BMW"
if a<b: d containt BMW
print("a is less than b")
if d in c: a is odd number
print("d is found in c")
if d=="BMW":
print("d containt BMW")
if a is b:
print("a and b are same")
if a%2:
print("a is odd number")

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

one of the conditions is true


Logical Operators:
AND- Return True if both are true True

OR- Return True if One true False

NOT- reverse, true to false, false to be true

Class 07 Enter a number: 10


Iteration:
The last Number you want print
While Loop Even number: 20
count=int(input("Enter a number: ")) 10
16
x=int(input("The last Number you want 11
print Even number: ")) 17
while(count<=x): 12
18
if(count%2==0): 13
19
print(count)
14
else: 20
print(count) 15
count+=1
Class 08
Continue Loop Continue Loop
count=0 Hello 1
while count<5:
count+=1 Hello 2
if count==3:
continue Hello 4
Hello 5
print("Hello",count)

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

You might also like