小编Jar*_*bcd的帖子

你能在这个 for 循环中使用浮点数吗?

我需要帮助。我试图让我的 for 循环使用小数,但我的代码不接受浮点数,我不确定下一步该怎么做。谁能指出我哪里出错了?

它是用于按用户定义的步骤 (Delta) 将摄氏温度转换为华氏温度的代码。这里是:

def main():

    # Handshake
    print("This program will convert a range of Celsius degrees to")
    print("Fahrenheit degrees based on your input.")

    # Ask and read low end of range
    Rangelow = eval(input("Enter the low end of your range: "))

    # Ask and read top end of range
    Rangehigh = 1 + eval(input("Enter the high end of your range: "))

    # Ask and read Delta
    Delta = eval(input("Enter the Delta for your range: "))

    #Display output …
Run Code Online (Sandbox Code Playgroud)

for-loop user-input range python-3.x

2
推荐指数
1
解决办法
9437
查看次数

标签 统计

for-loop ×1

python-3.x ×1

range ×1

user-input ×1