Installation of Python under Linux
Although my Unbuntu 10.11 version has been updated by default for Python installation, here's a re-introduction to how to install Python under Linux. There are also some installation tutorials on the web.
Pick up the following
1. Download Source Codes http://www.python.org/ftp/python/2.5.2/Python-2.5.2.tar.bz2
2. Installation
$ TAR–JXVF python-2.5.2.tar.bz2
$ CD Python-2.5.2
$./configure
$ make
$ make Install
3. Testing
Entering Python at the command line means that the Python interpreter appears to be installed correctly.
In Suse10 or Rhel5 (ES5) The system has Python installed by default, but the version is 2.4.x;
After this installation, enter in the shell
#python
You will find the results shown:
# python python 2.4.3 (#1, Dec 11 2006, 11:38:52)
[GCC 4.1.1 20061130 (Red Hat 4.1.1-43)] on linux2
Type "Help", "copyright", "credits" or "license" for more information.
>>>
Version is still 2.4.x.
Workaround:
#cd/usr/bin
#ll |grep python//view Python under this directory
#rm-RF python
#ln-S Prefix/python-2.5.2/python./python//prefix to unzip the Python directory for you
#python
# python
Python 2.5.2 (#1, Dec 11 2006, 11:38:52)
[GCC 4.1.1 20061130 (Red Hat 4.1.1-43)] on linux2
Type "Help", "copyright", "credits" or "license" for more information.
>>>
Ok! Problem Solving!
And that's the way it is in the textbook.
Provide administrator privileges first (root)
Apt-get Install Python
Python operations
>>> 6+7 >>> x=3 >>> print x 3 >>> x*4 >>> x=input ("x:") x:13 >>&G T Y=input ("y:") y:14 >>> print x+y >>> if 1==2:print ' Hello World ' ... >>> if 1==1:print ' Hello World ' ...
2. Same attention to division, redundancy, Root, and other operations
ABS (number) returns the absolute value of a digit
CMATH.SQRT (number) returns the square root of a digit
Math.ceil (number) returns the count of the top integer, type floating-point
Math.floor (number) returns the next integer with the type floating-point number
Repr (object) returns a string representation of merit
Str (object) Converts a value to a string
3.exit () function exits the Python command interface
4. Also in Linux you can build a text document in which to write Python code. and saved as a. py file. Then enter the file directory in the terminal, input the command
Python hello.py//Assuming that the hello.py file is saved
5. Comments, annotated with # in Python
6. String, where even a function of STR and repr the first one is to convert the value to a valid string, and the latter is to create a string. In fact, STR is a type and the latter is a function
>>> Print str ("Hello World") Hello World >>> print repr >>> x=str (" Hello world ") >>> y=repr >>> x+y ' Hello world45 '
Comparison of 7.input and Raw_input
The input statement can only receive a valid Python expression, such as the string is "Hello World" and should not be HelloWorld.
Raw_input won't have this kind of trouble.
|
|
| Day |
a |
two |
three |
Four |
Five |
Six |
| 25 |
26 |
27 |
28 |
29 |
30 |
31 |
| 1 |
2 |
3 |
4 |
5 |
6 |
7 |
| 8 |
9 |
10 |
11 |
12 |
13 |
14 |
| 15 |
16 |
17 |
18 |
19 |
20 |
21st |
| 22 |
23 |
24 |
25 |
26 |
27 |
28 |
| 29 |
30 |
1 |
2 |
3 |
4 |
|
Basic introduction to Python under Linux