day1- exercises

# 1, while loop input. 5. 4. 3. 6 2 1. 9 10. 8 
COUNT = 1 while COUNT <. 11:      # used while statement input loop 10 ... 123 if COUNT ==. 7:    # used in the if statement Pass, the 7 skipped input Pass the else :
         Print (COUNT) 
    COUNT + =. 1
 Print ( ' ------- ------- End ' )
 # ############# #### 
# 2, find all numbers 1-100 and 
TEMP. 1 = 
SUM = 0
 the while TEMP <101 : 
    SUM = SUM + TEMP 
    TEMP + =. 1
 Print

    
        
    (SUM)
 Print ( ' ------- ------- End ' )
 # ################ 
# . 3, the output of all of the inner 1-100 odd 
COUNT =. 1 the while COUNT <101 : 
    n- = COUNT 2%
     IF n-== 0:
         Pass the else :
         Print (COUNT) 
    COUNT + =. 1
 Print ( ' ------- ------- End ' )
 # 4, the output of all the even within 1-100 
COUNT =. 1 the while COUNT <101 : 
    n- = COUNT 2% IF n-== 0:
        

    


    print(count)
    else:
        pass
    count += 1
print('-------end-------')
################
# 5、求1-2+3-4+5 ... 99的所有数的和
count = 1
sum1 = 0
sum2 = 0
sum = 0
while count <100:

    if count %2:
        sum1=sum1+count
    else:
        sum2 = sum2 +count
    sum = sum1 - sum2
    count += 1
print (sum)
print('-------end-------')

m =1
s=0
while m<100:
    j = m%2
    if j==0:
        s = s -m
    else:
        s = s +m
    m = m +1
print(s)
print('-------end-------')

 

Guess you like

Origin www.cnblogs.com/mada1027/p/11613594.html