如何允许某人输入值前面带有"$"的浮点整数.例如,他们可以输入"4.25美元",也可以输入"4.25".
此外,当我在计算器中输入"4.35"时,提示出现"0.6".在我在家里拥有的计算器上它是0.6525.我如何得到完整的答案?
input ('Please Enter to begin')
while True:
print('This calculator will display the tip you owe for your meal price.')
mealPrice = int(float(input('Enter your meal price:')))
asw = mealPrice * 0.15
print('The tip you owe is: $',asw)
endProgram = input ('Do you want to restart the program?')
if endProgram in ('no', 'No', 'NO', 'false', 'False', 'FALSE'):
break
Run Code Online (Sandbox Code Playgroud) 我有点知道该怎么做,但我无法弄清楚。该程序需要能够获取学生姓名和三项考试成绩,然后获取三项成绩的平均分(百分比)。之后,您需要将分数(百分比)转换为等级。
编辑: 我如何删除成绩中间的空格和“%”?
分级量表:

input ('Please press "Enter" to begin')
while True:
import math
studentName = str(input('Enter your Name: '))
firstScore = int(float(input('First test score: ').replace('%', '')))
secondScore = int(float(input('Second test score: ').replace('%', '')))
thirdScore = int(float(input('Third test score: ').replace('%', '')))
scoreAvg = (firstScore + secondScore + thirdScore) / 3
def grade():
if scoreAvg >= 93 and <= 100:
return 'A'
if scoreAvg <= 92.9 and >= 89:
return 'A-' …Run Code Online (Sandbox Code Playgroud)