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