1. Use while loop to input 1 2 3 4 5 6 8 9 10
# Author:Tony.lou i = 1 while i < 11: if i == 7: pass else: print (i) i+=1
2. Find the sum of all 1-100
# Author:Tony.lou i = 0 n = 0 while i <100: tmp = i % 2 if tmp == 0: n = n - i else: n = n + i i = i + 1 print(n)
print(sum(i for i in range(1,101)))
3. Output all bases within 1-100
i = 0 while i < 101: tmp = i % 2 if tmp != 0: print(i) else: pass i+=1
for i in range(1,100,2): print(i)
4. Find the sum of all numbers 1-2+3-4+5..99
# Author:Tony.lou i = 0 n = 0 while i <100: tmp = i % 2 if tmp == 0: n = n - i else: n = n + i i = i + 1 print(n)
5. User logs in three times
count = 0 while count < 3: user = input('user:') password = input('password:') if user == 'tony' and password =='Omd': print('welcome') print('........') break else: print('error..try again') count += 1