print("Amrita vishwa vidyapeedam")
Amrita vishwa vidyapeedam
#be careful with the language
print("Hello, World!")
Hello, World!
x=5
y='Amrita'
print(x)
print(y)
5
Amrita
x,y,z= "Orange","Banana","Cherry"
print(x)
Orange
x=y=z="Orange"
print(x)
print(y)
print(z)
Orange
Orange
Orange
x=10
y=5
print("x+y =",x+y)
print("Addition of {}+{} gives ".format(x,y),x+y)
print("Subtraction of {}+{} gives ".format(x,y),x-y)
print("Product of {}+{} gives ".format(x,y),x*y)
print("Quotient of {}+{} gives ".format(x,y),x/y)
print("floor divison of {}+{} gives ".format(x,y),x//y)
print("Modulus of {}+{} gives ".format(x,y),x%y)
print("exponential of {}+{} gives ".format(x,y),x**y)
x+y = 15
Addition of 10+5 gives 15
Subtraction of 10+5 gives 5
Product of 10+5 gives 50
Quotient of 10+5 gives 2.0
floor divison of 10+5 gives 2
Modulus of 10+5 gives 0
exponential of 10+5 gives 100000
import math
x=-4.5678894
print(math.ceil(x))
-4
import math
x=4.3456777
print(math.ceil(x))
import math
x=4.1234455
print(math.ceil(x))
x = 4.5467
print (math.floor(x))
integer = -20
print('Absolute value of -20 is:', abs(integer))
Absolute value of -20 is: 20
a = 33
b = 200
if b > a:
print("b is greater than a")
b is greater than a
a = 33
b = 33
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
a and b are equal
a = 200
b = 33
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
else:
print("a is greater than b")
a is greater than b
PROBLEM 1
FINAL POPULATION
x=int(input("Enter the amount of intial people presentin the town:"))
y=int(input("Enter the amount of people left the town:"))
z=int(input("Enter the amount of people immigrated the town:"))
print("Total population=",x+z-y)
Enter the amount of intial people presentin the town:3
Enter the amount of people left the town:2
Enter the amount of people immigrated the town:5
Total population= 6
for i in range(4):
x=int(input("Enter the amount of intial people presentin the
town:"))
y=int(input("Enter the amount of people left the town:"))
z=int(input("Enter the amount of people immigrated the town:"))
print("Total population=",x+z-y)
Enter the amount of intial people presentin the town:3
Enter the amount of people left the town:1
Enter the amount of people immigrated the town:2
Total population= 4
Enter the amount of intial people presentin the town:2
Enter the amount of people left the town:2
Enter the amount of people immigrated the town:2
Total population= 2
Enter the amount of intial people presentin the town:4
Enter the amount of people left the town:1
Enter the amount of people immigrated the town:8
Total population= 11
Enter the amount of intial people presentin the town:10
Enter the amount of people left the town:1
Enter the amount of people immigrated the town:10
Total population= 19
PROBLEM 2 POLYBAGS
for i in range(3):
N=int(input("Enter the no of items bought from the shop:"))
p=N//10
if N%10==0:
print("The no of bags required is:",p)
else:
print("The no of bags required is:",p+1)
Enter the no of items bought from the shop:20
The no of bags required is: 2
Enter the no of items bought from the shop:24
The no of bags required is: 3
Enter the no of items bought from the shop:99
The no of bags required is: 10
PROBLEM 3 FRUITCHAAT
for i in range(3):
x=int(input('enter the amount of bananas present:'))
y=int(input("enter the amount of apples present:"))
print("THE NO OF CHAATS HE CAN MAKE:")
chaats=0
while x>=2 and y>=1:
chaats+=1
x-=2
y-=1
print(chaats)
enter the amount of bananas present: 72
enter the amount of apples present: 50
THE NO OF CHAATS HE CAN MAKE:
36
enter the amount of bananas present: 38
enter the amount of apples present: 93
THE NO OF CHAATS HE CAN MAKE:
19
enter the amount of bananas present: 51
enter the amount of apples present: 4
THE NO OF CHAATS HE CAN MAKE:
4
PROBLEM 4 MINICOINS
for i in range(3):
x= int(input("Enter the minimum no of coins chef needs"))
if x%10==0:
print(x//10)
elif x%10!=0 and x%5==0:
print((x//10)+1)
else:
print(-1)
Enter the minimum no of coins chef needs 50
Enter the minimum no of coins chef needs 15
Enter the minimum no of coins chef needs 8
-1
HOMEWORK
PROBLEM 1 REACHFAST
t=int(input("Enter the amount of test cases:"))
for i in range(t):
a=int(input("enter the intial coordinate of chef:"))
b=int(input("enter the intial coordinate of chefina:"))
k=int(input("enter the maximum no of coordinate chef can move in
one step:"))
if a==b:
print("""No need for any steps chef is in the same coordinate
as chefina
or the no of minimum steps needed for chef to reach chefina is
0""")
elif b>a:
if (b-a)%k==0:
print("the minimum no of steps needed by chef to reach
chefina is:",(b-a)//k)
else:
distance=abs(b-a)
print("the minimum no of steps needed by chef to reach
chefina is:",(distance//k)+1)
else:
distance=abs(b-a)
if distance%k==0:
print("the minimum no of steps needed by chef to reach
chefina is:",distance//k)
else:
print("the minimum no of steps needed by chef to reach
chefina is:",(distance//k)+1)
Enter the amount of test cases: 4
enter the intial coordinate of chef: 10
enter the intial coordinate of chefina: 20
enter the maximum no of coordinate chef can move in one step: 3
the minimum no of steps needed by chef to reach chefina is: 4
enter the intial coordinate of chef: 36
enter the intial coordinate of chefina: 36
enter the maximum no of coordinate chef can move in one step: 5
No need for any steps chef is in the same coordinate as chefina
or the no of minimum steps needed for chef to reach chefina is
0
enter the intial coordinate of chef: 50
enter the intial coordinate of chefina: 4
enter the maximum no of coordinate chef can move in one step: 100
the minimum no of steps needed by chef to reach chefina is: 1
enter the intial coordinate of chef: 30
enter the intial coordinate of chefina: 4
enter the maximum no of coordinate chef can move in one step: 2
the minimum no of steps needed by chef to reach chefina is: 13
PROBLEM 2 SONGS
t=int(input("enter the no of test cases:"))
for i in range(t):
x=int(input("enter the duration of the songs:"))
n=int(input("enter the duration of minutes he travelled:"))
print("The no of times he played the song c completely
is:",n//(3*x))
enter the no of test cases: 5
enter the duration of the songs: 1
enter the duration of minutes he travelled: 6
The no of times he played the song c completely is: 2
enter the duration of the songs: 1
enter the duration of minutes he travelled: 5
The no of times he played the song c completely is: 1
enter the duration of the songs: 2
enter the duration of minutes he travelled: 11
The no of times he played the song c completely is: 1
enter the duration of the songs: 8
enter the duration of minutes he travelled: 5
The no of times he played the song c completely is: 0
enter the duration of the songs: 9
enter the duration of minutes he travelled: 100
The no of times he played the song c completely is: 3