Python Beginner (1)

Source: Internet
Author: User

I. Data type
All programming languages are type-based, and Python is no exception. Python provides the following basic data types:
Int,float,complex (plural), string (Python has no single character type)
Two. Python variables
Python-defined variables do not require a write variable type, but initialization is required, and the interpreter automatically sets the variable type based on the data type. (Note: Python is case sensitive)
Three. Keywords
False Boolean value that represents false, contrary to True
None None is more special, it means nothing, it has its own data type-nonetype.
True Boolean-type value that represents true, contrary to False
And for expression arithmetic, logic and manipulation
As for type conversion
Assert assertion, used to determine whether the value of a variable or conditional expression is true
Break interrupts the execution of a loop statement
Class is used to define classes
Continue jump out of this loop and proceed to the next loop
DEF is used to define a function or method
Del Delete the value of a variable or sequence
Elif conditional statements, used in conjunction with IF, else
Else conditional statement, used in conjunction with IF, elif. can also be used for exceptions and looping statements
Except except contains an action code block after catching an exception, used in combination with try, finally
Finally is used for exception statements, and after an exception occurs, always executes the code block that finally contains. Used in combination with try, except
For For Loop statement
From for importing modules, using with import
Global variables defined
If condition statement, used in conjunction with else, elif
Import is used for importing modules in combination with from
In to determine if the variable is in the sequence
is to determine if a variable is an instance of a class
Lambda defines anonymous functions
nonlocal variables used to identify external scopes
Not for expression operations, logical non-operation
or used for expression arithmetic, logic, or manipulation
Placeholder for pass empty class, method, or function
Raise exception throw operation
Return returns the result of the calculation from the function
Try try to include statements that may have exceptions, used in conjunction with except, finally
While Loop statement
With simplified Python statements
Yield is used to return a value from a function sequentially
(The keyword module provides a sub-keyword to determine the function Keyword.iskeyword (), if the keyword returns true)

Four. Input and output

Input ()
Print ()
The controls are:%d,%f,%s

Five. Basic syntax
Except that the format differs from the C language, and there is no switch statement, the three structures are basically the same as the C language.

Six......
Actually learned C language, this is still very simple

Python Beginner (1)

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.