Python3 自学笔记02 分支与循环

1、if语句

a = input("please input a number as A:")
b = input("please input a number as B:")

if a > b:
    print("the bigger number is A")

elif b > a:
    print("the bigger number is B")

else:
    print("A=B")

2、for语句

list1 = ['lily', 'tom', 'amy']

for i in list1:
    print("%s is in the list"%i)

for j in range(0,len(list1)):
    print("%s is in the list"%list1[j])

3、while语句

n = 100
list1 = []

while n != 0:
    list1.append(n)

print(list1)

 

你可能感兴趣的:(Python3自学笔记)