python-First day Learning python

Source: Internet
Author: User

1, Python language can use the development tools are: Charles, fiddles, etc...

2, language classification: compiled and interpreted type, compiled type such as: C, C + +, C # .... Interpreted type: Python, java, php .....

3. Set Python in Pycharm

Set fields such as

Git.exe must be placed in the installation directory \program Files (x86) \git\cmd\git.exe

3, import the Get file, as follows

4. Variables in the Python language

In the Python language, instead of adding a type to a variable like any other language, the variables in Python are simple enough to give a variable name and assign a value

such as: Name= "Zhang San" The type is a string type and "" defines

Age=20 the type is a data type

Output the following example

name= ' Zhang San '
print ("My name is%s, this year%d, cash only%r, bought%.2f things."% ( Name,age,money,price))

The output in%s%d%r%s represents a dot character, and the output is a string type
%d represents a point character, and the output is a data type
%r represents a point character that is used when you do not know what type to output
And%.f, representing how many decimal places to follow, 2f is two decimal places, 3f is 3 decimal places, and so on

5. Shortcut keys in the Python language
ctrl+d Quick Copy Line
ctrl+/Quick Comment line, quick uncomment

6, the output, the use of single and double quotation marks
When to use single quotes, when to use double quotes
If there is a single quotation mark inside the sentence, use double quotation marks outside, if there is double quotation mark in the sentence, the outside is enclosed in single quotation marks, if there is a single quotation mark in the sentence, and there is double quotation mark, it is "" ' three single quotation mark
Three quotation marks also have comments on the function ' ' ' comments, comments, notes '
Example: Let's go output syntax for print ("Let's Go")
I am a "little bird" output syntax for print (' I am a ' little bird ')
Let's go, the "tart" output syntax for print ("Let's Go," "The Sao Year")

7. Input Syntax
input receives a string type and must be coerced if it needs to be converted to another type
Example: Name=input (' Please enter your name: ')
age=input (' Please enter your Age: ')
Age=int (age)
money=inptu (' Please enter your money: ')
can also be written directly as Age=int (input (' Please enter your name: '))
print (' My name is%s, age is:%d, how much money do you have:%s '% (Name,age,money))
can also be written in the following format
Print (name+ ' age is: ' +age+ ', ' +name+ ' has ' +money+ ' money ')

8. Judgment

All the judgments in Python are if-elif-else.

For example, the following determines the data type

Score=int (Input (' Please enter your score: '))
If Score>=60 and score<70:
Print (' Pass ')
Elif score>=70 and score<90:
Print (' Your grades in general ')
Elif score>=90:
Print (' Your Line of Excellence ')
Print (' Your grades fail ')

And the judgment of the character type.
The character type equals "= =", not equal to "! ="
Name=input ("Please enter your name:")
If name== ' Zhang San ':
Print ("hahaha")
Print ("hehe")

9. Circulation
Loops generally consist of two, while,for
While: A counter must be defined, the following example i=i+1 is equivalent to a counter
While i<5:
Print (i)

When a break is encountered in the loop, the loop is immediately ended
While i<5:
Print (i)
If i==2:
The output is: 0, 1

Continue: End this cycle, inherit the next loop, example
While i<5:
If i==4:
Print (' Output result:%d '%i)

python-First day Learning python

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: 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.