1
Python 第一周

2
Python 第一周
参考代码如下:

n = eval(input())
if n == 0:
print(“Hello World”)
elif n > 0:
print(“He\nll\no \nWo\nrl\nd”)
else:
for c in “Hello World”:
print©
答案可以有很多种写法。

第二种:
num = eval(input())
str = ‘Hello World’
if num==0:
print(str)
elif num>0:
for item in range(0,len(str),2):
print(str[item:item+2])
else:
for item in str:
print(item)

3Python 第一周

参考答案如下:

s = input()
print("{:.2f}".format(eval(s)))
体会eval()函数的作用,在编程中用处很大。

4
Python 第一周
chiStr = [‘零’,‘一’,‘二’,‘三’,‘四’,‘五’,‘六’,‘七’,‘八’,‘九’]
intStr = input()
for i in intStr:
b=eval(i)
print(chiStr[b],end=’’)

5
Python 第一周

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-24
  • 2021-12-08
  • 2022-12-23
  • 2021-05-09
猜你喜欢
  • 2021-09-06
  • 2021-06-30
  • 2022-12-23
  • 2022-01-08
  • 2022-01-05
  • 2021-11-05
  • 2021-04-01
相关资源
相似解决方案