Uploaded by 2084 Sanjana Goyal

Python Assignment No.1

advertisement
Name- Sanjana Goyal
Class-Cs B Cs -05
Roll No.-12112084
1. import math
tempC=input("Enter the temperature in celsius ")
F=(9/5)*int(tempC)+32
print("The temperature in fahrenheit is "+str(F))
Output:
2. import math
r=input("Enter the radius ")
l=input("Enter the length ")
Area=int(r)*int(r)*math.pi
Volume=int(Area)*int(l)
print("The area of cylinder is "+str(Area))
print("The volume of cylinder is "+str(Volume))
Output
3. import math
r=input("Enter the number of feet ")
Meter=int(r)*3.05
print("The meter of given feet "+str(r)+" is "+ str(Meter))
Output
4. import math
r=input("Enter the weigth in pounds ")
Kg=int(r)*0.454
print("The kilograms of given pounds "+str(r)+" is "+ str(Kg))
Output
6. import math
x1=input("Enter the x coordinate of
y1=input("Enter the y coordinate of
x2=input("Enter the x coordinate of
y2=input("Enter the y coordinate of
z1=int(x1)*int(x1)+int(y1)*int(y1)
z2=int(x2)*int(x2)+int(y2)*int(y2)
t=z1+z2
f=math.sqrt(int(t))
print("The square root of the given
1st
1st
2nd
2nd
point
point
point
point
")
")
")
")
coordinates is "+ str(f))
Output
7. import math
kg=int(input("Enter the amount of water "))
intialTemp=int(input("Enter the intial temp. "))
finalTemp=int(input("Enter the final temp. "))
energy=kg*(finalTemp-intialTemp)*4184
print("The energy needed is "+ str(energy))
Output
5. import math
r=int(input("Enter a number "))
list=[]
for i in range (2,r+1) :
flag=0;
for t in range (2,i) :
if i%t==0 :
flag=1
if flag==0 :
list.append(i)
t=len(list)
h=0
sum=0
while(h<t) :
sum=sum+list[h]
h=h+1
print("The sum of prime numbers less than or equal to "+str(r)+ " is "+
str(sum))
Output
Download