CSE039 Lab 1
CSE039 Lab 1
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))
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 = 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
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)
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)
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)
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)
-1
HOMEWORK
PROBLEM 1 REACHFAST
PROBLEM 2 SONGS