Python:结果打印顺序错误

时间:2017-11-17 04:55:38

标签: python python-3.x output

我目前的代码存在问题。我首先打印结果,然后在结束之前打印我的文字。

 #   program that converst C to F in a table
def main():
    print('The given table converst Celsius to Farenheit.');
    print('Celsius  \t  Farenheit');

for C in range(1,21):
    F=(9/5)*C+32;
    print( C,"  {0:.1f}".format(F));

main()

给我结果

1   33.8
2   35.6
3   37.4
4   39.2
5   41.0
6   42.8
7   44.6
8   46.4
9   48.2
10   50.0
11   51.8
12   53.6
13   55.4
14   57.2
15   59.0
16   60.8
17   62.6
18   64.4
19   66.2
20   68.0

The given table convert Celsius to Fahrenheit.

Celsius       Fahrenheit

如果你能帮助我解决这个非常感激的问题。

1 个答案:

答案 0 :(得分:1)

至于循环是主要定义,首先是循环执行然后是main()。在主要定义中移动for循环后,它应该正常工作。

color=colors.hsv_to_rgb(((i/n)**(1/2), 1, 1))
相关问题