怎样赋值 求求求
math=input("数学成绩:")chinese=input("语文成绩:")
english=input( "英语成绩:")
math and chinese and english = float
sum=(math+english+chinese)
print("总分:",sum,"平均:", sum/3 )
怎样三赋一 math and chinese and english = float
求求求{:9_221:} math=input("数学成绩:")
chinese=input("语文成绩:")
english=input( "英语成绩:")
math,chinese,english = map(float,(math,chinese,english))
sum=(math+english+chinese)
print("总分:",sum,"平均:", sum/3 ) math=input("数学成绩:")
chinese=input("语文成绩:")
english=input( "英语成绩:")
sum=float(math)+float(english)+float(chinese)
print("总分:",sum,"平均:", sum/3 )
三位一体赋值
>>> a,b,c=4,5,6
>>> a
4
>>> b
5
>>> c
或者:
>>> a=b=c=6
>>> a
6
>>> b
6
>>> c
6
把int直接改为float就可以了,应该是最简单的操作吧。{:10_258:}{:10_258:}{:10_258:}{:10_258:}
math=float(input("数学成绩:"))
chinese=float(input("语文成绩:"))
english=float(input( "英语成绩:"))
sum=(math+english+chinese)
print("总分:",sum,"平均:", sum/3 ) print("数学成绩为: ", math := float(input("数学成绩")), "语文成绩为: ",chinese := float(input("语文成绩")), "英语成绩为: ", english := float(input("英语成绩")), "\n总分: ", sum := (math + english + chinese), "\n平均分: ", average_mark := sum/3)
页:
[1]