Lec 3
Lec 3
a = 10 #int
b = 5.5 #Float
c = "UMT" #string
print(a, type(a))
print(b, type(b))
print(c,type(c))
width = 10
height = 5
print(width*height)
Hello
10 <class 'int'>
5.5 <class 'float'>
UMT <class 'str'>
50
50
Hello
10 <class 'int'>
5.5 <class 'float'>
UMT <class 'str'>
50
50
v1 = 20
v2 = 20
if v1<v2:
print("TRUE")
elif v1>v2:
print("Condition 2")
else:
print("False")
False
#Loops
for i in range(1,10):
print(i)
print("LOOP")
#a = 10; n = 1
a,n = 10,1
while n<=a:
print("n = ", n)
n += 1;
1
LOOP
2
LOOP
3
LOOP
4
LOOP
5
LOOP
6
LOOP
7
LOOP
8
LOOP
9
LOOP
n = 1
n = 2
n = 3
n = 4
n = 5
n = 6
n = 7
n = 8
n = 9
n = 10
A <class 'str'> 1
Bb <class 'str'> 2
Ccccc <class 'str'> 5
Dddd <class 'str'> 4
Eee <class 'str'> 3
Ffff <class 'str'> 4
Gg <class 'str'> 2
def addition(a,b):
c = a + b
print("Sum = ", c)
v1 = 15; v2 = 23
addition(10,20)
addition (v1,v2)
def subtraction(a,b):
c = a - b
return c
print("Sub = ",subtraction(v1,v2))
sub = subtraction(120,200)
print("sub = ", sub)
HEELO WORLD
PYTHON
AI
Sum = 30
Sum = 38
Sub = -8
sub = -80
def fib(n):
a,b=0,1
i=1
while i<=n:
print(a, end=" ")
a,b=b,a+b
i+=1
fib(70)
print(Greetings("ABC", "DEF"))
print(Greetings("XYZ", "123", False))
Mr. ABC DEF
Hello XYZ 123
Hello
World
UMT AI Course
123
AI LAB123
AI LAB123
AI LAB123
AI LAB123
AI LAB