Re-learning Python-day 02-python Foundation, if statement application + while loop application

Source: Internet
Author: User

If statement applied--Maximum value
1 """2 find the maximum value in three digits and print it out3 """4a = Int (input ("A:"))5b = Int (input ("B:"))6c = Int (input ("C:"))7 8 ifA>B:9Max_num =aTen     ifMax_num >C: One         Print(max_num) A     Else: -         Print(c) - Else: theMax_num =b -     ifMax_num >C: -         Print(max_num) -     Else: +         Print(c) -  + Print(Max (A,B,C))#built-in functions A Print(min (a,b,c))#built-in functions
While Loop

Example 1: Output an even number between 1 and 100 (but I think my program is so stupid)

1 """2 an even number between 1 and 100 outputs3 """4A =05  whileA < 101:6      forIinchRange (101):7         ifi%2 = =0:8             Print. IO9i + = 1Ten     ifI > 100: One          Break A         

Simplified:

A = while a < 101:    if a%2 = = 0        :print(a)    + = 1

Note: When the conditional judgment statement, must be in the program to do flase interrupt, or will continue to run indefinitely

Re-learning Python-day 02-python Foundation, if statement application + while loop application

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.