Study notes (15): zero-base mastering Python entry to actual combat-judgment sentences, acting by chance

Learn now: https://edu.csdn.net/course/play/26676/338784?utm_source=blogtoedu

Conditional statements:

if (the condition is true, the code block under it is executed):

Indent code blocks with four spaces

Rest code

if():

elif () :

elif () :

else:

import random 

random.randint() Randomly generates an integer.

Ternary operation:

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

When x>2, a = python, otherwise a = physics

 

 

 

 

Guess you like

Origin blog.csdn.net/m0_49939521/article/details/108597444