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

What is the usage of python if else?

coldplay.xixi
Release: 2020-06-24 09:00:55
Original
11354 people have browsed it

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)
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template