学习笔记(15):零基础掌握 Python 入门到实战-判断语句,见机行事

立即学习:https://edu.csdn.net/course/play/26676/338784?utm_source=blogtoedu

条件语句:

if(条件为真,则执行其下的代码块):

缩进四个空格 代码块

其余代码

if():

elif():

elif():

else:

import random 

random.randint() 随机生成一个整数。

三元操作:

a = 'python' if x>2 else 'physics'

当x>2时 a= python 否则 a= physics

猜你喜欢

转载自blog.csdn.net/m0_49939521/article/details/108597444