h=input() n=int(input()) s=0 while n>0: s+=h+h0.52 h=h0.5 n-=1 print('%.2f'%h)Traceback…
Jump to turn (16)
- 1h=input() n=int(input()) s=0 while n>0: s+=h+h0.52 h=h0.5 n-=1 print('%.2f'%h)Tr
- 2in chinese
- 3h=float(input()) n=int(input()) s=0 while n>0: s+=h0.52+h h=h0.5 n-=1 print('%.2
- 4h=float(input()) n=int(input()) s=0 while n>0: s+=h0.52+h h=h0.5 n-=1 print('%.2
- 5也不对啊,输出29.53,不是29.38
- 6for in range(n):这是什么东西啊
- 7h=float(input()) n=int(input()) s=0 while n>0: s+=h0.5+h h=h0.5 n-=1 print('%.2f
- 8可是我就要用while
- 9h=float(input()) n=int(input()) s=0 while n>0: s+=h0.5+h h=h0.5 n-=1 print('%.2f
- 10不是啊,这个是错的,输出错误结果
- 1110 6 29.53??????????????????????????????????????????????????????????????????????
- 1210 6 29.53
- 132023-2024(2)基础题库练习:第6章 编程题 题库:高度反弹 【问题描述】一球从 h 米高度自由落下, 每次落地后反跳回原高度的 0.5倍; 再落下,
- 1410 6 29.53给你最后一次机会改正
- 15不是,有区别吗
- 16我知道醉了,真是令人无语
- User
h=input() n=int(input()) s=0 while n>0: s+=h+h0.52 h=h0.5 n-=1 print('%.2f'%h)Traceback (most recent call last): File "C:\Users\86152\Desktop\Python\编程\练习0.py", line 5, in s+=h+h0.5*2 TypeError: can't multiply sequence by non-int of type 'float'
Assistant
The error you're encountering is because you're trying to perform arithmetic operations on a variable
hthat is of typestr. When you use theinput()function without specifying a conversion, Python treats the input as a string.To fix this issue, you need to convert the input to a numeric type, such as an integer or a float, depending on your needs. Since you're performing arithmetic operations that involve fractions and decimals, it's best to convert to a float.