小编Jor*_*lop的帖子

Python:在float整数前面允许"$"符号

如何允许某人输入值前面带有"$"的浮点整数.例如,他们可以输入"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)

python calculator

0
推荐指数
1
解决办法
351
查看次数

Python:如何在我的评分系统计算器中添加“最终成绩”转换器

我有点知道该怎么做,但我无法弄清楚。该程序需要能够获取学生姓名和三项考试成绩,然后获取三项成绩的平均分(百分比)。之后,您需要将分数(百分比)转换为等级。

编辑: 我如何删除成绩中间的空格和“%”?

  • 请按“Enter”开始
  • 输入您的名字:乔丹·辛普森
  • 第一次测试成绩:67%
  • 第二次测试成绩:78%
  • 第三次测试成绩:89%
  • 最终字母等级:C+
  • 乔丹·辛普森测试分数为:78.0 %
  • 您想重新启动该程序吗?

分级量表:

分级量表


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)

python

0
推荐指数
1
解决办法
1万
查看次数

标签 统计

python ×2

calculator ×1