标签:style 打印 控制流 print integer pytho sed 包括 个数
在Python 中有三种控制流语句——if、for 和while。 1.if语句Number = 23 Guess = int(input(‘Enter an integer : ‘)) if Guess == Number: print(‘Congratulations, you guessed it.‘) print(‘(but you do not win any prizes!)‘) elif Guess < Number: print(‘No, it is a little higher than that‘) else: print(‘No, it is a little lower than that‘) print(‘Done‘)
number = 23 Running = True while Running: Guess = int(input("Enter an integer:")) if Guess == Number: print("Congratulations, you guessed it.") elif Guess < Number: print("No, it is a little higher.") else: print("No, it is a little lower.") else: print("the while loop is over.") print("Done")
Enter an integer : 50 No, it is a little lower. Enter an integer : 22 No, it is a little higher. Enter an integer : 23 Congratulations, you guessed it. The while loop is over. Done
for i in range(1,5): print(i) else: print("The for loop is over")
标签:style 打印 控制流 print integer pytho sed 包括 个数
原文地址:http://www.cnblogs.com/w1ng/p/6610923.html