n =float(input("Enter a degree in celsius:"))
fahrenheit =(9/5)* n +32print("%g Celsius is %g Fahrenheit"%( n , fahrenheit ))
第二题
需要注意题中输入是用逗号隔开。然后调用math函数中的π,做运算即可。
import math
r , h =map(float,input('Enther the radius and length of acylinder:').split(','))
s = math.pi * r * r
t = s * h
print('The area is %g'%s)print('The volume is %g'%t)
第三题
y =float(input("Enter a volue for feet:"))
m = y *0.305print("%g feet is %g meters"%( y , m ))
第四题
注意保留小数点后一位
m = float(input("Enter a amount of water in kilograms:"))
c = float(input("Enter a initial temperature:"))
z = float(input("Enter a final temperature:"))
q = m * ( z - c ) * 4184
print("The energy needed is %.1f" %q )
第五题
c,l =map(float,input("Enter balance and interest rate(e.g., 3 for 3%): ").split(','))
s = c *( l /1200)print("The interest is %g"%s )
第六题
v0,v1,t =map(float,input("Enter v0,v1, and t:").split(','))
a =( v1 - v0 )/ t
print("The average acceleration is %g"%a )
第七题
m =float(input("Enter the monthly saving amount:"))
n =0
s=0while s <6:
n =( n + m )*(1.0+0.00417)
s = s +1print("The average acceleration is %g"%n )
第八题
m =int(input("Enter a number between 0 and 1000 :"))
s =0while m >0:if m >0:
s = s + m %10
m = m //10print("The sum of the digits is %d"%s )
第九题
s =25.0/4.0
d =25/4print("25/4d等于%g"% s )print('将其转变为整数为%d'% d)
m =int(input("输入一个需要判断奇偶的数:"))if m %2==0:print('{0}是偶数'.format(m))else:print('{0}是奇数'.format(m))
t =int(input("输入一个秒数:"))
f = t //60
miao = t %60print('%d转换成分和秒等于: %d分%d秒'%( t , f , miao ))
weekday =int(input("请输入今天是星期几:"))
daytime =int(input("请输入想知道几天后是星期几:"))
day = daytime %7
week =0-(7- weekday )+ day
print('10天以后是星期%d'% week)