Python 入門指南 V2.00 - 單元 6 範例及練習程式碼



select_demo.py


print()
if 3 > 5:
   print("Oh! 3 is bigger than 5!")
elif 4 > 5:
   print("Oh! 4 is bigger than 5!")
elif 5 > 5:
   print("Oh! 5 is bigger than 5!")
elif 6 > 5:
   print("Of course! 6 is bigger than 5!")
else:
   print("There is no case :(")
print()
  
# 檔名: select_demo.py 
# 作者: Kaiching Chang 
# 時間: July, 2014

select_demo2.py


print()
s = 6
if s == 3:
   print("3...")
elif s == 4:
   print("4...")
elif s == 5:
   print("5...")
elif s == 6:
   print("6...")
else:
   print("There is no case :(")
print()
  
# 檔名: select_demo2.py 
# 作者: Kaiching Chang 
# 時間: July, 2014

exercise0601.py


a = 3
b = 5
if a == b:
   print("a == b")
else:
   print("a != b")
 
# 檔名: exercise0601.py 
# 作者: Kaiching Chang 
# 時間: July, 2014

exercise0602.py


a = int(input("a: "))
b = int(input("b: "))
if a == b:
   print("a == b")
else:
   print("a != b")
 
# 檔名: exercise0602.py 
# 作者: Kaiching Chang 
# 時間: July, 2014

exercise0603.py


g = int(input("g: "))
if g < 60:
   print("Bad!")
elif 60 <= g < 70:
   print("Not Bad")
elif 70 <= g < 80:
   print("Good!")
elif 80 <= g < 90:
   print("Great!")
elif 90 <= g < 100:
   print("Excellent!")
elif g == 100:
   print("Perfect!")
else:
   print("Pardon?")
 
# 檔名: exercise0603.py 
# 作者: Kaiching Chang 
# 時間: July, 2014

the end

沒有留言: