Little Turtle Python Video Sixth lecture (Notes and program source code)

Source: Internet
Author: User

Today I learned mainly about the main points of the cycle,

1.use ofelif

 whiletrue:temp= Input ("Please enter a score:") score=int(temp)if  ->= score >= -: Print ("A") Elif ->= score >= the: Print ("B") Elif the>= score >= -: Print ("C") Elif ->Score:print ("D")    Else: Print ("Input Error")

2. Use ofassert :

When the following condition is true, the error occurs when the condition is false.

3. Ternary conversion

4,5if x > y    = yelse:    = x

Equivalent to:

if Else y

That is, the x if condition else y

Noun Explanation:

Membership operators

Hands-on section: The classification of fractions, adding a cycle of their own parts,

 whiletrue:temp= Input ("Please enter a score:") score=int(temp)if  ->= score >= -: Print ("A") Elif ->= score >= the: Print ("B") Elif the>= score >= -: Print ("C") Elif ->Score:print ("D")    Else: Print ("Input Error")

(note not added, back one by one plus)

Score =int(Input ('Please enter a score:'))if  the> Score >= -: Print ('C') Elif -> Score >= the: Print ('B') Elif -> Score >=0: Print ('D') Elif ->= score >= -: Print ('A')Else: Print ('input Error! ')

(Source code)

On the ternary conversion

6 5 4 if x < y:    = x    if z < small:        =< z:< c13/>= yelse:    = Z
if Else if else z)

Little Turtle Python Video Sixth lecture (Notes and program source code)

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.