###########作业1###########
#将摄氏温度转化为华氏温度
#华氏温度(fahrenheit) =(9/5)* 摄氏温度(celsius) + 32
‘’’
celsius = int (input(‘Enter a degree in Celsius:’))
fahrenheit = (9 / 5) * celsius + 32
print (’%d Celsius is %.2f Fahrenheit’ %(celsius,fahrenheit))
‘’’
###########作业2###########
#编写一个读取圆柱的半径和高并利用下面的公式计算圆柱体底面积和体积的程序
#area = radius * radius * π
#volume = area * length
‘’’
r,l = map(float,input(‘Enter the radius and length of a cylinder:’).split())
π=3.1415926
area = r * r * π
volume = area * l
print (‘The area is %.2f’ %area )
print (‘The volume is %.2f’ %volume )
‘’’
##############作业3###########
#将英尺转换成米
‘’’
feet = float(input(‘Enter a value for feet:’))
meters = feet * 0.305
print (’%.4f feet is %.4f meters:’%(feet,meters))
‘’’
##############作业4###########
#计算水烧的能量
#Q = M(最终温度-初始温度)* 4184
‘’’
M = float(input(‘Enter the amount of water in kilogram:’))
initial = float(input(‘Enter the initial temperature:’))
final = float(input(‘Enter the final temperature:’))
Q = M * ( final - initial ) * 4184
print (‘The enegry needed is %.4f’%Q)
‘’’
##############作业5###########
#计算利息
#利息=差额*(年利率/1200)
‘’’
chae, nianll = map (float,input(‘Enter balace and interest rate (e.g.,3 for %3):’).split())
lixi=chae * (nianll / 1200)
print (‘The interest is %f’ %lixi)
‘’’
##############作业6###########
#加速度算法
‘’’
v0,v1,t = map (float,input(‘Enter v1 v2 and t:’).split())
a=(v1-v0)/t
print (‘The average acceleration is %f’ %a)
‘’’
##############作业7###########
#金融复利算法
#初始账户a
‘’’
amount = int(input(‘Enter the monthly saving amount and month :’))
money=0
for i in range(6):
money = ( money + amount ) * (1 + 0.004417)
print(‘six month later money is =%.4f’%money)
‘’’
############作业8####5#######
#对一个整数中的各位数字求和
‘’’
num = int(input(‘Enter number between 0 - 1000 :’))
ge = num % 10
bai = num // 100
shi = (num - bai * 100 - ge ) // 10
plus = ge + shi + bai
print (‘The sum of the digits is : %d’ %plus)
‘’’
############EP1###########
a = 25 // 4
print (‘25/4的整数是:%d’ %a)
############EP2###########
‘’’
num = int (input(‘输入一个数字:’))
if (num % 2 == 0 ):
print(’%d 是偶数’%num)
else:
print(’%d 是奇数’%num)
‘’’
############EP3###########
‘’’
sum = int(input(‘输入秒数:’))
fen = sum / 60
miao = sum % 60
print(’%d秒等于%d分钟%d秒’%(sum,fen,miao))
‘’’
############EP4###########
after = int (input(‘多少天之后:’))
xingqi = 6
#因为定义星期一到星期六是1-6,星期天是0
day = (6 + after) % 7
if (day == 0 ):
print(‘这天是星期天’)
else:
print(‘这天是星期%d’%day)