# lesson 8 if 複数の条件分岐(授業練習用) ## 授業でスライドにあるコードを練習する。HackMDに書いたコードをコピーして、実行した結果をスクリーンショットして貼り付けてください。 ## 例: :::info Code: ```python= r = float(input("Please input value r:")) r_Round = r * 2 * 3.14 r_Area = r * r * 3.14 print("The round:", r_Round) print("The area:", r_Area) ``` 結果: ![](https://i.imgur.com/u7n9gvs.png) ::: --- ## 1. :::info Code: ```python= money=int(input("please enter your money:")) if money >=500: print("カプチーノ") if money >=600: print("モカ") if money >=380: print("エクスプレッソ") if money >=560: print(”ラテ”) if money >=470: print("アメリカーノ") ``` 結果: ::: --- ## 2. :::info Code: ```python= score=int(input("score:")) if score >=90: print("grade is : A") else: if score >=80: print("grade is : B") else: if score >=70: print("grade is : C") else: if score >=60: print("grade is : D") else: print("grade is : F") ``` 結果: runfile('C:/Users/user/untitled8.py', wdir='C:/Users/user') score:90 grade is : A runfile('C:/Users/user/untitled8.py', wdir='C:/Users/user') score:74 grade is : C ::: --- ## 3. :::info Code: ```python= score=int(input("score:")) if score >=90: print("grade is : A") elif score >=80: print("grade is : B") elif score >=70: print("grade is : C") elif score >=60: print("grade is : D") else: print("grade is : F") ``` 結果: runfile('C:/Users/user/untitled9.py', wdir='C:/Users/user') score:73 grade is : C runfile('C:/Users/user/untitled9.py', wdir='C:/Users/user') score:87 grade is : B ::: --- ## 4. :::info Code: ```python= year = int(input("please input year:")) if(year % 400== 0): print("{} is a leap year.".format(year)) else: if(year % 100 == 0): print("{} is a normal year.".format(year)) else: if(year % 4 == 0): print("{} is a leap year.".format(year)) else: print("{} is a normal year.".format(year)) ``` 結果: runfile('C:/Users/user/untitled10.py', wdir='C:/Users/user') please input year:45 45 is a normal year. runfile('C:/Users/user/untitled10.py', wdir='C:/Users/user') please input year:444 444 is a leap year. ::: --- ## 5. :::info Code: ```python= ``` 結果: ::: --- ## 6. :::info Code: ```python= ``` 結果: ::: --- ## 7. :::info Code: ```python= ``` 結果: ::: --- ## 8. :::info Code: ```python= ``` 結果: ::: --- ## 9. :::info Code: ```python= ``` 結果: ::: --- ## 10. :::info Code: ```python= ``` 結果: ::: --- ## 11. :::info Code: ```python= ``` 結果: ::: --- ## 12. :::info Code: ```python= ``` 結果: ::: --- ## 13. :::info Code: ```python= ``` 結果: ::: --- ## 14. :::info Code: ```python= ``` 結果: ::: --- ## 15. :::info Code: ```python= ``` 結果: ::: --- ## 16. :::info Code: ```python= ``` 結果: ::: --- ## 17. :::info Code: ```python= ``` 結果: ::: --- ## 18. :::info Code: ```python= ``` 結果: ::: --- ## 19. :::info Code: ```python= ``` 結果: ::: --- ## 20. :::info Code: ```python= ``` 結果: :::