Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7
ASSIGNMENT1 (PYTHON FUNDAMENTALS)
# calculate and display the sum of two numbers
a = int(input('enter the first number :'))
b = int(input('enter the second number :')) s=a+b print ('sum:' ,s)
enter the first number :7342
enter the second number :7350 sum: 14692 >>> #program to calculate area of the rectangle
L = float(input('enter the length of rectangle :'))
B = float(input('enter the breath of rectangle :')) area = L * B print(area)
enter the length of rectangle :65
enter the breath of rectangle :34 2210.0 >>> # calculate and display % of student appearing in five subjects
a = float(input('enter the subject 1 marks :'))
b = float(input('enter the subject 2 marks :')) c = float(input('enter the subject 3 marks :')) d = float(input('enter the subject 4 marks :')) e = float(input('enter the subject 5 marks :')) percentage = (a+b+c+d+e)/500*100 print('percentage :' ,percentage)
enter the subject 1 marks :98
enter the subject 2 marks :78 enter the subject 3 marks :96 enter the subject 4 marks :87 enter the subject 5 marks :80 percentage : 87.8 >>> # program to find simple interest
P = float(input('enter the principle amount :'))
R = float(input('enter the rate of interest :')) T = float(input('enter the number of years :')) SI = P*R*T/100 print(SI)
enter the principle amount :429430
enter the rate of interest :10 enter the number of years :4 171772.0 >>> # swap two numbers
a = float(input('enter the first number :'))
b = float(input('enter the second number :')) a,b = b,a print('first number after swap :',a) print('second number after swap :',b)
enter the first number :233
enter the second number :432 first number after swap : 432.0 second number after swap : 233.0 >>> # convert given time in sec, min and hrs