"Learning Notes" Python Basic Tutorial Learning Notes

Source: Internet
Author: User

Tutorial Video disc sharing: Http://pan.baidu.com/s/1hrTrR5E

03-python basis, if judgment

PrintOutput DataPrint("Hahahah")------>Hahahaha= 100Print(a)----->Direct printing of A's value a= 18Print("My age is%d years old."%a)------>my age is 18 years old.= 18 High= 178Print("My age is%d years, my height is%dcm"%(Age,high))#Note: The variables in% (Age,high) are sequential, that is, the value of age replaces the first%d, and high replaces the second%dPrint("aaaaaa", end="") output aaaaaa, but not newline name="Dongge"Print("My name is%s"%name) Input: UserName= Input ("Please enter user name:")------------------------------------------------------------Practice:#input information from the keyboard, and print the business card in a way to output#1. Prompt and get nameName = input ("Please enter your name:")#2. Tips and get contact informationTel = input ("Please enter your phone number:")#10086 number, "10086" string#3. Prompt and get addressaddr = input ("Please enter company address:")#4. Output InformationPrint("=======================")Print("Name:%s"%name)Print("phone Number:%s"%Tel)Print("Company Address:%s"%addr)Print("=======================") Money+ =------> Equivalent to Money = money+100 Money*= 3--------> Money = Money * 3A= 11A*= 3+4-6------->a = a*3+4-6---->a = 11*3+4-6---->of the wrong------->a = A * (3+4-6)---->a = 11* (3+4-6)---"Correct a= Int (" -")----"Put the string" -"a value of 100 (integer) that becomes an integer determines the statement:ifconditions: When the conditions are met, do things 1 when the conditions are met, do things 2 when the conditions are met, do things 3 when the conditions meet, do things 4ifcondition: When the condition is met, the thing to doElse: When the condition is not satisfied, the thing to do

04-python base-if, while, for, etc.

ifwhen judging a condition, if multiple conditions are being judged together, then a logical operator is required and-----> andor----->ornon-(take reverse)---> notifCondition 1 andCondition 2: Condition 1 and Condition 2 are satisfied, do things 1 condition 1 and Condition 2 are satisfied, do things 2 ... Wait a minute... Summary: Mode 1:ifConditions: Things to do when conditions are met 1 conditions to meet when the things to do 2 conditions meet when the things to do 3 .... Wait Way 2:ifConditions: Things to do when conditions are met 1 conditions to meet when the things to do 2 conditions meet when the things to do 3 .... WaitElse: Things to do when conditions are not met 1 conditions do not meet when the things 2 conditions do not meet the things to do 3 way 2:ifcondition 1: Condition 1 is satisfied when doing things 1 condition 1 satisfies the thing to do 2 condition 1 satisfies the thing to do 3 .... WaitelifCondition 2: Condition 2 do things when satisfied 1 conditions 2 do things when satisfied 2 conditions 2 things to do when satisfied 3elifCondition 3: Condition 3 do things when satisfied 1 conditions 3 do things when satisfied 2 conditions 3 things to do when satisfied 3Else: Condition 1,2, 3 are not satisfied with the case of the default execution of things, (note else can be no, according to the actual function to determine) if the condition 1 is satisfied, then the execution condition 1 is satisfied when the thing done, after the completion, the following conditions 2, 3 will not be executed, but directly end the entire if statement if the condition 1 is not satisfied, Then to determine whether the condition 2 is satisfied, if the condition 2 is satisfied, then the execution condition 2 is fulfilled when the code executes, and then ends the entire if statement if the condition 1, 2 is not satisfied, then the condition 3, if the condition 3 is satisfied, then the execution condition 3 is fulfilled, then the entire if statement endsifxxxx:yyyyyyyifXxxxx2:yyyyyyy2 Method 1 for repeating code execution:Print("dear, I was wrong, please forgive me ....")Print("dear, I was wrong, please forgive me ....")Print("dear, I was wrong, please forgive me ....")Print("dear, I was wrong, please forgive me ....")Print("dear, I was wrong, please forgive me ...."Method 2 To repeat code execution:ifconditions: When conditions are met, things to do whileconditions: Things to do when the condition is met note the point:1What exactly is the condition while,,, , Tip: Find the code that needs to be executed repeatedly, and then on the condition while you can2. How many times is it executed? ,,, Little tricks: Look at demand, in the case of unclear requirements, do not know exactly how many times, then use whileTrue3. I= 1 whilei<=10:        Print("haha")

"Learning Notes" Python Basic Tutorial Learning Notes

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.