# 第六支程式 #判斷式 if布林值一:若布林值一為True,執行命令 elif布林值二:若布林值為二為True,執行命令 else:布林值一和二都False,執行命令 範例:x=input("請輸入數字:")# 基本輸入為字串型態 x=int(x) #轉換為整數型態 if x>200:print("大於200") elif x>100: print("大於100,小於200") else:print("小於100") #四則運算 n1=int(input("請輸入數字一: ")) n2=int(input("請輸入數字二:")) op=input("請輸入運算:+, -, *, /: ") if op=="+": print(n1+n2) elif op=="-": print(n1-n2) elif op=="*": print(n1*n2) elif op=="/": print(n1/n2) 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