#What is the usage of python if else?
python if else usage:
The statement structure of if-else is what operation is performed when the previous condition is established, then the following branch structure will not be Execute, if the previous condition is not true, otherwise do the following.
Judgment:
1) If the scores in the three subjects are >= 60 points, the prompt is: Congratulations, you passed the exams in all subjects!
2) If there is a subject with a score of
Operation code: Code abbreviation Please refer to the demonstration picture
Chinese = int(input("请输入语文成绩:")) Maths = int(input("请输入数学成绩:")) English = int(input("请输入英语成绩:")) course = "" if Chinese >= 60 and Maths >= 60 and English >= 60: print("恭喜你,通过了所有科目的考试!") else: if Chinese < 60: course += "语文 " if Maths < 60: course += "数学 " if English < 60: course += "英语 " print("很遗憾,没有通过所有考试,需补考科目:" + course)
Demo results:
Recommended tutorial: "python video tutorial"
The above is the detailed content of What is the usage of python if else?. For more information, please follow other related articles on the PHP Chinese website!