Python learning notes (1), python learning notes

Source: Internet
Author: User

Python learning notes (1), python learning notes

In fact, you can find a happy way to learn every language. If you are interested or have fun, you will always want to learn. Knowing print (), input (), and if/else can make a simple game.

Print () # print function, print the information out input () # print the information, and require that you enter a paragraph, and put this paragraph. If 1 + 1 = 2: print ('I am real, if 1 + 1 is equal to 2, it will print me !!! ') Else: print (' I am a false employee. If 1 + 1 is not equal to 2, it will print me ~~~ ') # Condition judgment statement
 

Then we can start playing the game through the three BIF functions learned above:

Print ('----------- WordGame -----------') number = int (input ("guess the number given by the system:") if number = 8: print ("wow, guessed it !! ") Else: print (" wrong! The number given by the system is 8! ")
Print ('----------- WordGame -----------')

 

Input function. This function displays the string on the IDLE and allows the user to input information and save this information to the number.

Note: input is of the string type by default. Here, we use int () to directly convert the input information to the int type.

Number = int (input ("guess the number given by the system :"))

 

The condition judgment statement is expressed in Chinese. If the number is 8, "Wow, guess" is printed. If the number is 8, "guess wrong!" is printed !"

If number = 8: print ("wow, guess it !! ") Else: print (" wrong! The number given by the system is 8! ")
Program flowchart

If you do not know how to break down a function, it is easier to understand it. If you write a program to draw a picture, the idea will be clear, and what you do is not easy to make mistakes.

>>> If c = 1: SyntaxError: invalid syntax

Summary of this learning function

Print () Print function
Input () Input Function
Dir (_ builtins __) View BIF
Help (print) Help
If and else Judgment statement

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.