= 60 print("passed")]."/> = 60 print("passed")].">

Home  >  Article  >  Backend Development  >  What is the usage of python if else?

What is the usage of python if else?

coldplay.xixi
coldplay.xixiOriginal
2020-06-23 15:20:2411303browse

What is the usage of python if else?

#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:

What is the usage of python if else?

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn