Python Basics (operators, lists, dictionaries, nesting, traversal, functions)

Source: Internet
Author: User
Tags types of functions

Python basics, operators, lists, dictionaries, nesting, traversal, functions
Operator: +–*///%
Self-increasing self-reduction squared self-removal ....
Comparison Operators! = Not equal to = = equals <>
Eg:a = 1 B = 3 a<>b not equal to Ture <= >=
logical operator or OR and and not
Linux hit code fill CTRL + N
If you need to be aware of the point indentation, add the following:
Linux edit error can jump directly past the method VI file name + wrong number of lines
Three major executions of the program
1. Sequential execution
2. Select Execute
3. Loop execution
While loop
If nesting a thing in another thing set up under the general only nested one
While nesting
While condition:
Conditions to meet the things to do
While condition 2:
Condition 2 Does the thing
End = "" does not break line
For break
Len () can see how many bytes the string occupies
Int ()
STR ()
String two ways of composing +%s
An element can take any one of the characters in a string by subscript
The list [] can have duplicate
Change and delete
Append () Last
Insert (position, content to add) the location you want to add
List can be directly added
Name = Extend (name1)
Delete Pop () deletes the last one by default
Rmove () Delete the first if there are duplicate deletions
Del list name del+ list name +[subscript]
Modify
List name [] = new
Check in Not in
Dictionary {}
Dictionary name [""] can index content
Del Delete
Dictionary name [] = add
Syntax for slices: [Start: End: Step]
PS: The selected interval is left closed right open type, that is, starting from the "start" bit, to the end of the first bit of the end (note: Does not include the end bit itself)
Subscript Note a[-x:]
Two ways to traverse
For in
While loop
else in for loop
The For loop performs else when it is traversed
Append extend differences in list
Append another equivalent to a whole filling in
Extend equivalent to merging
List Append points to note
Tuple ()
Can't change
can only view
Common operations
Len () Number of dictionary key-value pairs
Common dictionary Operations
. Keys ()
. VALUES ()
. Get ("")
If x in XX:
. Items ()
Unpacking can replace tuple elements with variables
A = (11,12)
C,d = A
c = 11
D =12
Function
def xx ():
This whole can also be said to be encapsulated
Functions with parameters
return value of returns
The value of a function cannot be taken directly to another function
The return value can be used to pass in the function curve passed in to the parameter.
You can return three values with a list (you can also use Ganso)
Function ends as soon as it runs to the return function
Return back as long as a whole can
Four types of functions
There are no parameters
There is no return value
There is no return value for function
There are functions that have return values
No parameter no return value
No parameter has a return value
Nested calls to functions
You can't theoretically have the same function name in a program.
function calls are not in any order
Functions can also be used with a while loop
51cto Address http://blog.51cto.com/n1lixing

New Ket Cinema http://www.ldxzs.top/shipin/shipin/

Webmaster Blog Address: http://www.ldxzs.top

Python Basics (operators, lists, dictionaries, nesting, traversal, functions)

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.