Day1 Python Primer

Source: Internet
Author: User

1. The first sentence of the Python statement

Print "Hello,world"

Execute file: Python hello.py

2. Variables

Note: variable names can only be any combination of letters, numbers, or underscores when defining variables, the first character of a variable name cannot be a number, and the Python keyword cannot be a variable.

2.1 Assignment of variables:

name1 = "Oldboy"

Print variable values

Print (NAME1)

3.python Interactive Input input

Name = input ("Please input name":)

Pring (name)

4. Number Types

I NT (integral type):

string:

In the definition of the value of the variable is quoted is a string, when the definition of the variable has multiple rows of values then we use the multi-quotes three quotation mark "" "to define

Boolean type:

Two values, a true (true), a false (false), mainly in mind to determine the logic

>>> a=3

>>> b=4

>>> a > 3

False

>>> a < 4

True

>>>

list type:

Definition, list nesting, Value column table values to use curly braces []

Test = [1,2,[4,5]]

Print (test[2][1])

List variable Increase append

Test.append ([5,6])

Dictionary type:

Only basic definition, value dictionary to use curly braces {}

dic={' name ': 2, ' name2 ': ' 3 '}

Print (dic[' name '])

dic[' name ']= ' body '

Print (DIC)

Day1 Python Primer

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.