- 运用输人输出函数编写程序.将华氏温度转换成摄氏温度。换算公式:C=(F-32)*5/9,其中C为摄氏温度,F为华氏温度。
f=float(input('请输入华氏温度:'))
c=(f-32)*5/9
print("摄氏温度:",c)
- 编写程序,根据输人的长和宽,计算矩形的面积并输出。
length=float(input("输入长度:"))
width=float(input("输入宽度:"))
s=length*width
print("面积为:" ,s)
- 编写程序,输入三个学生的成绩计算平均分并输出。
stu1=float(input("请输入第1个同学的成绩:"))
stu2=float(input("请输入第2个同学的成绩:"))
stu3=float(input("请输入第3个同学的成绩:"))
avg=(stu1+stu2+stu3)/3
print("平均成绩为:",avg)
- 根据以下叙述写出正确的条件表达式:
有语文Chine)数学(Math)、英语(Engish)三门课程,均采用百分制,60分及以上为及格,90分及以上为优秀。
(1)三门课程都及格;
(2)至少一门课程及格;
(3)语文及格且数学或者英语优秀。
Chinese=float(input("请输入语文成绩:"))
Math=float(input("请输入数学成绩:"))
English=float(input("请输入英语成绩:"))
if Chinese>=60 and Math>=60 and English>=60:
print("三门课程都及格")
elif Chinese>=60 or Math>=60 or English>=60:
print("至少一门课程及格")
elif Chinese>=60 and (Math>=90 or English>=90):
print("语文及格且数学或者英语优秀")