1. 程式人生 > >003 Python與類C語言的區別(未完)

003 Python與類C語言的區別(未完)

特點 .com 裏的 mar dom info pytho alt 溢出

#寫在前面的話:重點記錄Python的特點

Python特點:

1. 無分號斷句

技術分享圖片

2. 不用擔心溢出問題

技術分享圖片

3. if-else的用法不同

#if或else後面都要添加冒號:

import random
secret = random.randint(1,10)

print(-----我愛魚C工作室-------)
temp = input("不妨猜一下小甲魚現在心裏想的是哪個數字(3次機會):")
guess = int(temp)
cnt = 1

if guess == secret:
    print("我靠,你是小甲魚心裏的蛔蟲嗎?!
") print(哼,猜中了也沒有獎勵!) else: if guess > secret: #檢查標點符號,英文的冒號 print("哥,大了大了~~~") else: print("嘿,小了,小了~~~") while guess != secret and cnt < 3: temp = input(" 不好意思,猜錯了,重新輸入吧:") guess = int(temp) cnt = cnt + 1 if
guess == secret: print("我靠,你是小甲魚心裏的蛔蟲嗎?!") print(哼,猜中了也沒有獎勵!) else: if guess > secret: #檢查標點符號,英文的冒號 print("哥,大了") else: print("嘿,小了") print("遊戲結束,不玩啦^_^")

003 Python與類C語言的區別(未完)