Python learning notes (6) Python first program, learning notes python

Source: Internet
Author: User

Python learning notes (6) Python first program, learning notes python

Python statements

Assignment Statement

1. Assign the value of object 3 to variable.

2. assign values 3 and 4 to variables a and B.

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

3. Implement a, B = 3, 4 for a, B = 4, 3

1 >>>, B = 3, 4 generally, we declare a temporary variable to solve 2> temp = a 3> a = B 4> B = temp 5> a 6 4 7 >>> B 8 3 9 >>> B, a = a and B can be implemented in Python as the variable has no type and the object has a type of 10 >>> a11 312 >>> b13 414 >>>

4. the first program Hello Word

I. Create a New py file helloword. py with the following content:

print "hellword"

Execute in command line (cmd)

1 G:\pythonWorkspace>2 G:\pythonWorkspace>python helloword.py3 hellword

Ⅱ, the arithmetic program creates the file study. py, the content is

① The first action is used to specify the interpreter for executing the script and tell the computer the name of the execution program in the system variable.

② Second behavior encoding format is set to UTF-8

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

1 #! /Usr/bin/env python 2 # coding: UTF-8 3 4 "5 Calculate 6 56 + 8*5-18/9 7" 8 9 a = 56 + 8*5-18/9 # arithmetic operation 10 print
1G: \ pythonWorkspace> execute 2 94 in the python study. py command line

 

  

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.