L = [ [‘Apple‘,‘Google‘,‘Microsoft‘], [‘Java‘,‘Python‘,‘Ruby‘,‘PHP‘], [‘Adam‘,‘Bart‘,‘Lisa‘] ] #打印Apple print(L[0][0]) #打印Python print(L[1][1]) #打印Lisa print(L[2][2]) age =20 if age >= 18: print(‘your age is‘,age) print(‘adult‘) else: print(‘your age is‘,age) print(‘teenager‘) s = input(‘birth:‘) birth = int(s) if birth < 2000: print(‘00前‘) else: print(‘00后‘) height = 1.75 weitht = 80.5 bmi = weitht / (height*height) print(bmi) if bmi <18.5: print("过轻") elif bmi >= 18.5 and bmi <25: print("正常") elif bmi >= 25 and bmi< 28: print("过重") elif bmi >= 28 and bmi <32: print("肥胖") else: print("严重肥胖") sum = 0 for x in range(101): sum = sum + x print(sum) Name = [‘Bart‘,‘Lisa‘,‘Adam‘] for xxx in Name: print("Hello",xxx ,‘!‘) b = 0 ... while b <= 2: print("Hello",Name[b],‘!‘) b = b +1
下一步准备学习dict 和 set
时间: 2024-10-12 15:52:09