0011 _ exercise questions, 0011 exercise questions
_ Author _ = 'prop 93 '#! /Usr/bin/env python #-*-coding: UTF-8-*-# Use a while LOOP to input 1 2 3 4 5 6 8 9 10a = 1 while True: print () if (a = 10): break if (a = 7): a + = 1 continue a + = 1
_ Author _ = 'prop 93 '#! /Usr/bin/env python #-*-coding: UTF-8-*-# Calculate the sum of all numbers 1-100 and a = 1sum0 = 0 while (a <= ): sum0 = sum0 + a + = 1 print (sum0)
_ Author _ = 'prop 93 '#! /Usr/bin/env python #-*-coding: UTF-8-*-# output all odd numbers a = 1 while (a <101): if (a % 2! = 0): print (a) a + = 1
_ Author _ = 'prop 93 '#! /Usr/bin/env python #-*-coding: UTF-8-*-# output all the even numbers in 1-101 a = 1 while (a <): if (a % 2 = 0): print (a) a + = 1
_ Author _ = 'prop 93 '#! /Usr/bin/env python #-*-coding: UTF-8-*-# evaluate 1-2 + 3-4 + 5 .... sum of all numbers of 99 # method 1 # sumj = 0 # sumo = 0 # I = 1 # while (I <100): # if (I % 2 = 0 ): # sumo + = I # else: # sumj + = I # I + = 1 # print (sumj-sumo) # Method 2: I = 1he = 0 while (I <100): if (I % 2 = 1): he + = I else: he-= I + = 1 print (he)
_ Author _ = 'prop 93 '#! /Usr/bin/env python #-*-coding: UTF-8-*-# User Logon (three retries) wtime = 1 while (wtime <= 3 ): user = input ("Username:") pwd = input ("Password:") if (user! = "Xb" or pwd! = "123"): print ("Username or Password wrong, Please input again! (% D/3) "% wtime) wtime + = 1 else: print (" Login Succeed! ") Break