Python Learning Notes (vi) Python first program

Source: Internet
Author: User

Python statement

Assignment statements

1. Assign the 3 object to the variable a

2, 3, 4 is assigned to the variable, a, b

1 >>> a = 3       2 >>> A, B = 3,43 >>> a4 35 >>> b6 47 >>> a = 3,48 >>> a9 (3, 4)

3, the realization will a,b=3,4 exchange a,b=4,3

1>>> b =3,4 Generally we declare a temporary variable to resolve2>>> temp =a3>>> A =b4>>> B =Temp5>>>a647>>>b839>>> b,a=This can be done in Python, because the variable has no type and the object has a typeTen>>>a One3 A>>>b -4 ->>>

4. First program Hello Word

Ⅰ Create a new py file helloword.py with the following

Print " Hellword "

Execute at command line (CMD)

1 g:\pythonworkspace>2 g:\pythonworkspace>python helloword.py3 Hellword

Ⅱ Four operator creates a new file study.py with the contents of

① The first behavior is used to specify the interpreter that executes the script, telling the computer that the program executes the name of the system variable

② second behavior encoding format set to UTF-8

③ third line three double or three single quotation marks for document comments

  1  #  !/ Usr/bin/env python   2  #  coding:utf-8   3   4  Span style= "COLOR: #800000" "" ""   5   calculation   6  56+8*5-18/9   7    8   9  A = 8 * 5-18/9 #   arithmetic  
    
     10 
     print  a 
1 g:\pythonworkspace>python study.py    command line execution 2 94

  

Python Learning Notes (vi) Python first program

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.