Learn Python 006: if Statements

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Learn Python 006: if Statements相关的知识,希望对你有一定的参考价值。

# Booleans & Comparison Operators
# True
# False
# =
# ==
# !=
# <
# >
# <=
# >=


# if statements

num1 = 100
num2 = 100
if num1 > num2:     #this is not true, so it‘s gonna print the later statement
    print(‘num1 is bigger than num2‘)
else:
    print(‘num2 is bigger than num1‘)

# this is how you do it:

num3 = 500
num4 = 500
if num3 > num4:
    print(‘num3 is bigger than num4‘)
elif num4 > num3:
    print(‘num4 is bigger than num3‘)
else:
    print(‘num3 equals num4‘)

 

以上是关于Learn Python 006: if Statements的主要内容,如果未能解决你的问题,请参考以下文章

Python初级006-循环语句

first-Python基础判断语句006

火炉炼AI机器学习006-用决策树回归器构建房价评估模型

火炉炼AI深度学习006-移花接木-用Keras迁移学习提升性能

Python_if语句。 Learn python the hard way_扩展练习。习题29

006_go语言中的if else条件语句