Python origin variable and if loop

Source: Internet
Author: User

One. The origins of Python
Python is an interpreted weak-type programming language.
Features: Simple. Clear. Elegant

Two. Python's Interpreter
CPython. provided by the official. Internal use of C language to achieve
PyPy. Interpret our code as a bytecode file at once. can go directly to run.

Three. The first Python program
Print (any content)

Print (3+5+6) print ((3+5+6) *12) print (((3+5+6) *12) +3)

  

Four. Variable
The intermediate values that are generated during the run of the program. Temporarily saved in memory. For use in later programs
Naming rules:
1. Use letters, numbers, underscores
2. Cannot start with a number, not a pure number
3. You cannot use the Python keyword
4. Not too long
5. To make sense
6. Case-sensitive
7. Do not use Chinese
8. It is recommended to use the hump or underline

A = 3+5+6     # Here's a is a variable. Temporarily records a value. For subsequent programs to continue using Execute print (a*12)     # 168
b = A       # execution order. Assigns the value to the right of the equal sign to the variable to the left of the equal sign print (b)     #168

Five. The data type of the variable
1. Int. Integer. Can do +,-, *,/,% (calculates remainder, modulo),//(divisible)

Print (10%3) print (10//3)

2. Str. String. can be + * ', ', ' ', ' "", "the lavish content called string

Alex = "" "Black Eat" "" type () to see the data type of the variable alex = 18print (Alex) s = "The girl across the street looked over and looked over." It's hard to resist. Arrangement ' Print (s)

3. bool. Boolean value.   A value of two. True, False can only be used to determine the condition


Six. User interaction
variable = input (Prompt)

variable = input ("prompt") content = input ("Did you eat?") Print ("We received at the console:" +content) lets the user enter a, allowing the user to enter B. The computer calculates the result of a+b a = input ("Please enter A:") # input received is STRB = input ("Please enter B:") # input received is STR


The received content is a string type
str = > int + = int (str)

#将字符串转换成整数  Int (string) c = Int (a) + int (b) print (c)


Seven. Process Control (IF)

    If condition:        code block    If condition 1:        code block 1    Else:        code block 2    if condition 1:        code block    elif Condition 2:        code block elif ...    . else: If condition: If condition:                code block        else:    else:

 

Content = input ("Please enter if you have won:") if content = = ' is ': # = assignment.  = = Judge Print ("Go to the top    of Life")    print ("Buy it first 20 houses") Else: Print ("    live the life of the Cock")    print ("I'm going to die")

  

Print ("Crashed crashed crashed, who?") gender = input ("Excuse me, are you a man or a woman?") if gender = = ' man ':    Pass #  Pass. Indicates the integrity of the grammar    print ("The man went next door." Find Alex. ") else:   # is not a man's age    = input ("Dalglish this year?")    if int >: # input receives a string. 48 is int. These two data types are not comparable to        print ("Auntie, who are you looking for?")    Else:        print ("My melon, especially sweet.")

  

 

Python origin variable and if loop

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.