《 笨方法学 Python 》_ 习题 1

习题 1:第一个程序
print("Hello World!")
print("Hello Again")
print("I like typing this.")
print("This is fun.")
print("Yay! Printing.")
print("I'd much rather you 'not'.")
print('I "said" do not touch this.')

附加练习:

1. 让你的脚本再多带打印一行

print("Hello World!")
print("Hello Again")
print("I like typing this.")
print("This is fun.")
print("Yay! Printing.")
print("I'd much rather you 'not'.")
print("\n")
print('I "said" do not touch this.')

2. 让你的脚本只打印一行

print("Hello World!", end='')
print("Hello Again", end='')
print("I like typing this.", end='')
print("This is fun.", end='')
print("Yay! Printing.", end='')
print("I'd much rather you 'not'.", end='')
print('I "said" do not touch this.', end='')


通过 end='' 指定其以空白结尾,或 end=' ' 以空格结尾

3. 在一行的起始位置放一个“#”字符,它的作用是什么?

# 注释代码

猜你喜欢

转载自blog.csdn.net/yz19930510/article/details/80514539
今日推荐