grammar of python

lyrrr / 2024-09-02 / 原文

input:

default input is string
num=input()
num=int(input())//this can change the input type

loop:

instead of curly brackets, python identify code block by retract(indented)

for i int range(1,10,2):
//range is [1,10) which means [1,9]
for i in [2,5,"cheese",' ']:
  print(i*2)

//the output is:
4
10
cheesecheese

division

/is not rounded
\\ is rounded

if else :

if x and y:
    print(1)
elif x:
    print(0)
else:
    print(-1)