Python入门之练习作业

"""
作业:
1.三合一(图示,代码,理论)
2.当天练习独立完成
3.画出下列代码内存图
a = 1000
b = a
a = 5000
print(b) # ?
4.已知加速度,初速度,时间
计算:距离
加速度 = (距离 - 初速度 X 时间) * 2 / 时间平方
5.温度
摄氏度 = (华氏度 - 32)/ 1.8
华氏度 = 摄氏度 * 1.8 + 32
开氏度 = 摄氏度 + 273.15
(1)在控制台中获取华氏度,计算摄氏度。
(2)在控制台中获取,计算华氏度。
(3)在控制台中获取摄氏度,计算开氏度
6.(扩展)在控制台中获取总秒数,计算几小时零几分钟零几秒。
"""

作业3流程图:

 

 

# 作业4:
# distance 距离,initial_velocity 初速度,time  时间,accelerated_speed加速度
# 已知加速度,初速度,时间
#     计算:距离
#     已知,加速度 = (距离 - 初速度 X  时间) * 2 /  时间平方
#      得:距离  = 加速度  * 时间平方  * 0.5 + 初速度 x 时间
accelerated_speed = float(input("请输入加速度:"))
initial_velocity = int(input("请输入初速度:"))
time = int(input("请输入时间:"))
distance = accelerated_speed * time ** 2 * 0.5 + initial_velocity * time
print("距离是:" + str(distance))
#     作业5:温度
#     摄氏度 = (华氏度  - 32)/ 1.8
#     华氏度 = 摄氏度  * 1.8 + 32
#     开氏度 = 摄氏度 + 273.15
#     (1)在控制台中获取华氏度,计算摄氏度。
#     (2)在控制台中获取,计算华氏度。
#     (3)在控制台中获取摄氏度,计算开氏度
#     6.(扩展)在控制台中获取总秒数,计算几小时零几分钟零几秒。
#  Celsius_degree 摄氏度,fahrenheit 华氏度,Kelvin 开氏度
fahrenheit = float(input("请输入华氏度:"))
celsius_degree = (fahrenheit - 32) / 1.8
print("你的摄氏度是:" + str(celsius_degree))

#     华氏度 = 摄氏度  * 1.8 + 32
celsius_degree = float(input("请输入摄氏度:"))
fahrenheit = celsius_degree * 1.8 + 32
print("你的华氏度是:" + str(fahrenheit))

#     开氏度 = 摄氏度 + 273.15
celsius_degree = float(input("请输入摄氏度:"))
kelvin = accelerated_speed + 273.15
print("你的开氏度是:" + str(kelvin))
#  作业6:(扩展)在控制台中获取总秒数,计算几小时零几分钟零几秒。
# 1分钟 = 60秒   60分钟 = 1小时
# seconds 秒,minutes 分钟,hour  小时,total_seconds 总秒数
# 总秒数 = 秒数 * 60

total_seconds = int(input("请输入总秒数:"))
hour = total_seconds // 3600  # 小时
minutes = total_seconds // 60 % 60  # 分钟
seconds = total_seconds % 60  #
print("你的结果是:" + str(hour) + "小时" + str(minutes) + "" + str(seconds) + "")

 

posted @ 2023-01-23 14:45  黎小菜  阅读(158)  评论(0)    收藏  举报