1. Use while loop input 1 2 3 4 5 6 8 9 10
while Count <=: if count = = 7: = count + 1 continue Print (count) = Count + 1
2. For all numbers of 1-100
Count = 1 sum = 0while count <= 100:sum = sum + countcount = count + 1 print (sum)
3. All odd numbers in output 1-100
Count = 1 while Count <= 100:if count% 2 ==1:print (count) Count = count + 1count = count + 1
4. All even numbers in output 1-100
Count = 1while count <= 100:if count% 2 ==0:print (count) Count = count + 1count = count + 1
5, Beg 1-2+3-4+5 ... 99 of all numbers of the and
Count = 1 sum = 0 while Count <= 99:if count ==1:sum = Countcount = Count + 1continueelse:if count% 2 ==1:sum = sum + Countcount = count + 1else:sum = Sum-countcount = count + 1print (sum)
6. User Login (three chance retry)
Count = 1sum = 0while count <= 3:username = input (' Please enter user name: ') password = input (' Please enter user password: ') if username = = ' Jason ' and pass Word = = ' 123 ':p rint (' login successful, welcome ' Jason ' Back! ') Breakelse:sum = 3-countprint (' Username or password error, please re-enter, currently remaining ' +str (sum) + ' opportunity! ') Count = count + 1
Python basic job Exercise -20171214