Python Phase Summary

Source: Internet
Author: User

# #Python的基本语法
1. Basic input and Output statements print and raw_input ()
A data type built into the 2.list:python is a list. Lists is an ordered set of elements that can be added and deleted.
3. Tuple: Tuple and list are very similar, but tuple cannot be modified once initialized
4. Dictionary (dictionary): is the key-value pair
5. Iteration
6. Generation of Lists
7.if statements
8.while statements
9. Shaping int
10. Float Type Float
11. Long Plastic and so on
# #Python的程序结构: * Simple If statement: can contain any conditional test, and in the indentation code block immediately following the test, any action is performed. If the result of the condition test is true, Python executes the code immediately following the IF statement, otherwise Python ignores the code


```
Age = All if Age >= 18:
Print ("Enough to vote!")
```

* At the place, Python checks if the value of the variable age is greater than or equal to 18; The answer is yes, so Python executes the print statement indented at: *
* If-else statement: The IF-ELSE statement block is similar to a simple if statement, but the Else statement in it allows you to specify the action to be performed when the condition test fails. The IF-ELSE structure is well suited for situations where Python does one of two things. In this simple if-else structure, one of the two operations is always performed.
```
Age = 17
If age >= 18:
Print ("Enough to vote!")
Print ("Registered to vote yet?")
Else
Print ("Sorry, too young to vote.")
Print ("Register to vote as soon as turn 18!")
```


* Elif is an abbreviation for else if, there can be more than one elif, so the complete form of the IF statement is:
```
If < condition judgment 1>:
< Executive 1>
Elif < condition judgment 2>:
< Executive 2>
Elif < condition judgment 3>:
< Executive 3>
Else
< Executive 4>
```
* While loop: Runs continuously until the specified condition is not satisfied
```
Current_number = 1
While Current_number <= 5:
Print (Current_number)
Current_number + = 1
```
# #Python的函数
* Simple function structure:
1. function definition; 2. Comment of the document string; 3. code in function body; 4 Call function
* Arguments and formal parameters:

```
def greet_user (username):
"" Displays a simple greeting "" "
Print ("Hello," + username.title () + "!")
Greet_user (' Jesse ')
```

In the example above, the variable username is a formal parameter parameter-a function of the information required to complete its work. In Code greet_user (' Jesse '), the value ' Jesse ' is an actual argument. Arguments are information that is passed to the function when the function is called
* Return value: The function does not always display the output directly, instead it can process some data and return one or a set of values. The value returned by the function is referred to as the return value return value. In a function, you can use the return statement to return a value to the line of code that called the function. The return value allows you to move most of your program's heavy work to the function to complete, simplifying the main program
# #Python的模块:
* Store functions in modules: one of the advantages of functions is that they can be used to separate blocks of code from the main program. By assigning a descriptive name to a function, the main program is much easier to understand. Store the function in a separate file called a module module and import the module into the main program. The import statement allows the code in the module to be used in the currently running program file
* Import the entire module: to make the function can be imported, you have to create the module first. Module module is a file with a. py extension that contains the code to import into the program
* Methods for importing specific functions: from module_name import function_name
* All functions in the import module: the asterisk (*) operator allows Python to import all functions in the module

```
From Pizza Import *
Make_pizza (+, ' pepperoni ')
Make_pizza (' mushrooms ', ' green peppers ', ' extra cheese ')
```

# #总结:
Through a few weeks of study, let me have a basic understanding of the Pythone, let me also know the language, language and language have similar places, Python learning feel and Java similar, but there are very different, the whole learning process, let me realize that as long as serious study, there is a harvest , although the teaching process of this course will be finished, but I know that my learning steps can not stop, I will always learn about this only, improve their language skills.

Python Phase Summary

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.