Python development: First knowledge of Python

Source: Internet
Author: User

python Environment:

To install Python:

  Pyrhon installed on the OS, To perform the operation: write a file, the file in accordance with the rules of Python, the file to the Python software, read the contents of the file, then convert and execute, and finally get the results.

Windows:

1. Download the installation package    HTTPS://WWW.PYTHON.ORG/DOWNLOADS/2, install the    default installation path: C:\python273, configure    the environment variable "right-click Computer"-"Properties"--" Advanced system Settings "-" "Advanced"--"
"Environment variable"-"in the Second content box find a row of the variable named path, double-click the"-"Python installation directory appended to the variable value, use; split" such as: the original value; C:\python27, remember that there's a semicolon in front

  Linux:

No installation, original Python environment  PS: If you bring your own 2.6, please update to 2.7

Update python

 Windows:

Unloading load can be

Linux:

Linux Yum relies on its own python, to prevent errors, the update here is actually to install a python

View the default Python version python-v  1, install GCC, to compile the Python source    yum install GCC2, download the source package, HTTPS://WWW.PYTHON.ORG/FTP/PYTHON/3, Unzip and enter the source file 4, compile and install    ./configure make    install5, view version    /usr/local/bin/python2.7-v6, modify default Python version    mv/usr/bin/python/usr/bin/python2.6    ln-s/usr/local/bin/python2.7/usr/bin/python7, prevents Yum from performing exceptions, Modify the Python version Vi/usr/bin/yum used by Yum to    change the head #!/usr/bin/python to #!/usr/bin/python2.6
Getting started with Python:
A. Python basics-base 1, the first sentence python-suffix can be any? -When importing a module, if it is not a. py file ==> After the file suffix name is. py2, two ways to execute-the path of the Python interpreter py file-python into the interpreter real-time input and get to the execution result 3, the interpreter path #!/usr/bin/env Python4 , code #-*-Coding:utf8-*-ascii 00000000Unicode 00000000 00000000utf8 can use how much to express a summary: Python3 no attention to coding, python2 each file as long as the Chinese, the head Department must add (#-*-Coding:utf8-*-) 5, perform an action alert user input: User and password get username and password, detect: User name: Root, Password: 123456 Correct: Login Success Error: Logon failure a.input usage: Always wait, know that the user entered a value, the input value will be assigned to a thing 6, variable name-letter-number-underline special case: 1, can not start with the number 2, cannot be the keyword 3, It's best not to repeat what's built into Python. Pycharm Programming * * * * Supplement: 1, the variable name better have a meaning a bit 2, the word and the word with the underscore _ delimited 7, conditional statement if condition: print (' Statement 1 ') Else:print (' Statement 2 ') print (' Statement 3 ') INP = input (' Please enter: ' If InP = = "AAA":p rint (' 1111 ') elif INP = = ' BBB ':p rint (' 2222 ') elif INP = = ' CCC ':p rint (' 3333 ') else:print (' 4444 ') 8, String (quotation mark) name= "..."-addition n1 = ' alex ' n2 = ' sb ' n3 = ' db ' n3 = n1 + N2 +n3-Multiplication n1 = "Alex" N2 = N1 * 10-digit age = 13A1 = 10A2 = 20 addition : a3 = a1 + A2 subtraction: a3 = a1-a2 multiplication: a3 = A1 * A2 Division: a3 = 100/10-square operation: a3 = 4**4 modulo/remainder: a3 = 39 8 9, loop-Dead loop import timewhile 1 = =1:print (' OK ', time.time ()) Exercises: 1, using while loop input 1 2 3 4 5 6 8 9 102, all the number of 1-100 and 3, output 1-100 of all the odd 4, output 1-100 all even 5, all the number of 1-2+3-4+5...99 and 6, user login (three chance to retry) 

  

Python development: First knowledge of Python

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.