笨辦法學python3-練習 1. 第一個程序 課後練習

  1. 讓你的腳本再打印出一行。
  2. 讓你的腳本只打印一行。
  3. 在任一行的開頭放一個 # ,看看會發生什麼?試着弄明白這個符號的作用。

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.\n')

結果:

print("\n")是打印兩行;print("hello world\n")是多打印一行 或者 print ("") 也是多打印一行

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.\n',end="")

結果:

3.   #   爲註釋

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章