Luffy Learning City-python Development Training--the first chapter

Source: Internet
Author: User

Tag: Play hat error will lap + = info Oge while loop

1 language: Explanatory language, different from Java compiler

2 History of development

3 Installation

Win all the way next, configure the environment variables to verify that the installation is successful

4 variables and their variables function, range

1) Name: With numbers, letters and underscores.

2) cannot start with a number,

3) Avoid using System keywords

5 interaction

Input statement

Name = input ("what isyour name? ") "  = Int (input ("How old is? ") "  = input ("What isyour job? ") "  "'==========info of%s=========name:%sage:%sjob:%s========end ======='" %(name,name,age,job)print(info)
View Code

6 Type: Number, String, Boolean type, formatted output, operator

1) All default input is a string

2) Even if the number is also defaulted to a string, cast, such as the plus type such as the number int (5), float (6)

3) view type (variable name)

4) Boolean types are classified as true or false, with, or, non-

5) print ((%s,%s), (name,age)) Note one by one correspondence

7 Statement Control---If

1Name = input ("What is your name?")2Sex = input ("Boy or girl?")3age = Int (input ("How is old is you ?"))4 5 ifSex = ='Girl':6     ifAge <28:7         Print("I like girl")8     Else:9         Print("brother and sister Love is also very good oh")Ten Else: One     Print("Togerther come on")
View Code

8 Statement Loop while

Times =0 whileTimes <= 3: Guess_number= Int (Input ("Please enter a score:"))    ifguess_number>100:        Print("input error, out of")    elifGuess_number >= 90:        Print("level: A")    elifGuess_number >= 80:        Print("level: B")    elifGuess_number >= 60:        Print("Rating: C")    elifGuess_number >= 40:        Print("level D")    Else:        Print("E") Times+ = 1
View Code

9 dead Loop

 while True:     Print (" yo, really dead cycle oh ")

10 Jumping out of the loop break,continue difference

Replace break and continue in the following code to perform a view of the execution effect

Count = 0 while Count <=:    print(    count)if count = = 5:        continue    + = 1print("")
View Code

Break ends the current loop and proceeds to the next code

Continue jumps out of the current loop, does not execute the following statement, jumps to the current loop body and executes a new loop from the condition judge

While--else

The else function behind the while loop is to execute the ELSE statement when it is not aborted by a break in the middle of the normal execution.

Replace break and continue in the following code to perform a view of the execution effect

Count = 0 while count < 5:    Print(count)    +=1    if Count = = 3:        breakElse    :print ("  Loop normal ")    print("")
View Code

Luffy Learning City-python Development Training--the first chapter

Related Article

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.