Python Learning Exercise 1

Source: Internet
Author: User

#using while loop Output 1 2 3 4 5 6 8 9Count = 1 whileCount <= 10:    ifCount = = 7: Count+ = 1Continue    Print(count) Count+ = 1#all numbers of the 1-100 are calculated andCount = 1sum=0 whileCount <= 100: Sum+=Count Count= Count + 1Print(sum)#Find all the odd numbers within 1-100Count = 1 whileCount <= 100:    Print(count) Count= Count + 2#all even numbers in the output 1-100Count = 1 whileCount <= 100: Count+ = 1Print(count) Count+ = 1#To 1-2+3-4+5...99 all the numbers andCount = 1sum1= 1sum2= 1 whileCount < 100: Count+ = 1sum1+=Count Count+ = 1sum2+=CountPrint(sum2-sum1)#User Login (three chance retry)n = 1 forCountinch{1,2,3,4}:    ifN < 4: Name= Input ("Please enter your account number") Password= Input ('Please enter your password:')    Else:        Print('retry more than 3 times, please try again later')        Continue    ifName = ='Mao'  andPassword = ='Chun':        Print('welcome into the New World .')         Break    Else:        Print('you have incorrectly lost your account password%s times'%N)Print('Please re-enter your account number and password') n= n + 1

Python Learning Exercise 1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.