print("__1__") f = __2__ c = 5 * (f - 32 ) / 9 print ("%8.0f %8.2f" % (f , c))
时间: 2024-01-24 18:17:04 浏览: 64
可以通过填空题来学习Python语言的基础知识,下面是填好空的代码:
```python
print("__1__")
f = __2__
c = 5 * (f - 32 ) / 9
print ("%8.0f %8.2f" % (f , c))
```
其中,`__1__` 和 `__2__` 是需要填空的地方,具体填什么可以根据代码的语义和需求来判断。
如果我们想要输出一个字符串,可以在第一行填写:
```python
print("Hello, world!")
```
如果我们想要让用户输入一个数字,然后将其转换成浮点数,可以在第二行填写:
```python
f = float(input("Please enter a temperature in Fahrenheit: "))
```
这样,我们就可以让用户在控制台上输入一个数字,然后将其转换成浮点数,存储在变量 `f` 中。接下来,我们可以使用这个数字来计算摄氏温度,并将结果打印出来。
完整的代码如下所示:
```python
print("Convert temperature from Fahrenheit to Celsius.")
f = float(input("Please enter a temperature in Fahrenheit: "))
c = 5 * (f - 32 ) / 9
print ("%8.0f %8.2f" % (f , c))
```
这段代码会输出一个提示信息,让用户输入一个华氏温度,然后将其转换成摄氏温度,并将结果打印出来。
相关问题
print("__1__") f = __2__ c = 5 * (f - 32 ) / 9 print ("%8.0f %8.2f" % (f , c)) f = __3__ c = 5 * (f - 32 ) / 9 print ("%8.0f %8.2f" % (f , c)) f = __4__ c = 5 * (f - 32 ) / 9 print ("%8.0f %8.2f" % (f , c)) f = __5__ c = 5 * (f - 32 ) / 9 print ("%8.0f %8.2f" % (f , c)) f = __6__ c = 5 * (f - 32 ) / 9 print ("%8.0f %8.2f" % (f , c)) f = __7__ c = 5 * (f - 32 ) / 9 print ("%8.0f %8.2f" % (f , c))
print("__1__") f = __2__ c = 5 * (f - 32 ) / 9 print ("%8.0f %8.2f" % (f , c)) f = __3__ c = 5 * (f - 32 ) / 9 print ("%8.0f %8.2f" % (f , c)) f = __4__ c = 5 * (f - 32 ) / 9 print ("%8.0f %8.2f" % (f , c)) f = __5__ c = 5 * (f - 32 ) / 9 print ("%8.0f %8.2f" % (f , c)) f = __6__ c = 5 * (f - 32 ) / 9 print ("%8.0f %8.2f" % (f , c)) f = __7__ c = 5 * (f - 32 ) / 9 print ("%8.0f %8.2f" % (f , c))
答案:
__1__
32 __2__
212 __3__
0 __4__
20 __5__
-40 __6__
50 __7__
10.00
print("华氏温度 摄氏温度") f =__1__ while f __2__: c = 5 * (f - 32 ) / 9 print ("%8.0f %8.2f" % (f , c)) f = f + __3__
print("华氏温度 摄氏温度")
f = 0
while f <= 100:
c = 5 * (f - 32 ) / 9
print ("%8.0f %8.2f" % (f , c))
f = f + 10
这段代码是一个将华氏温度转换为摄氏温度的程序,其中的空缺填写如下:
__1__: 初始华氏温度,一般为 0
__2__: 循环条件,一般为小于等于 100,即转换到 100 度华氏温度为止
__3__: 单次循环结束后温度增加的值,一般为 10
阅读全文
相关推荐
















