7/9 Python Day 2 簡介+練習 === ###### tags: `Coding X` `Java` `programming` `學習筆記` > [time=Tue, Jul 9, 2019 9:27 AM] ### What can you do with python? - 資料探勘、分析 - 科學運算 - 機器學習 - Web網頁 - 遊戲 - GUI [實作練習](https://hackmd.io/@BDh7WDr4SoWSb5iOsd8uSw/wiasliawCodingX) ### Exercises 1 ```python= # Hi this is comment for this file # 該程式的問題是如果score大於70的話 # 就會永遠印出C 因為它符合elif之後就不會繼續往下執行 score = int(input("Please input score: ")) if score < 70: print('D') elif score >= 70: print('C') elif score >=80: print("B") elif score >= 90: print('A') print('End') ``` ### Exercise 2 ```python= # check year year = int(input("Please input year that you want to check: ")) if year%4 !=0: print(year,"是平年") elif year%4 == 0 and year%100 !=0: print(year,"是閏年") elif year%100 == 0 and year%400 !=0: print(year,"是平年") elif year%400 == 0: print(year,"是閏年") ``` ### Exercise 3 ```python= special = '16256802' #特別獎 specify = '33378146' #特獎 headers = '92040881' #頭獎 最左邊的號碼 extra_1 = '998' #增開六獎 1 extra_2 = '741' #增開六獎 2 extra_3 = '833' #增開六獎 3 extra_4 = '732' #增開六獎 4 # 如何判斷 number = input("Please input invoice number: ") extra = number [5:] if number == headers: print("中了頭獎") elif number == special: print("中了特別獎") elif number == specify: print("中了特獎") elif extra == extra_1 or extra == extra_2 or extra == extra_3 or extra == extra_4: print("中了增開六獎") else: print("沒中") ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up