python-Basic Introduction

Source: Internet
Author: User

First, the Linux Foundation
-Simple operation of the computer and the server that we developed later to prevent

Ii. development of Python
Http://www.cnblogs.com/wupeiqi/articles/5433893.html
Homework:
-Program
-Blog address (open blog) http://www.cnblogs.com/wupeiqi/articles/6084562.html
Http://www.cnblogs.com
Registered
Request a blog
Login
My blog
Essays: Articles that everyone can find in their blogs
Article: No one else can find it, access by URL
LOG: No one can find it, the URL is not visible

Development:

Development language:
High-level language: Python Java, PHP C # Go Ruby C + + ... = = = byte code
Low-level language: C, assembly = = = "Machine code

The contrast between languages:
PHP class: For writing Web pages, limitations
Python Java: And can write Web pages can also write background functions
-Python execution efficiency is low and development efficiency is high
-High execution efficiency and low development efficiency in Java

Python type:
Jpython
IronPython
Javascriptpython
Rubypython
CPython **********
...
PyPy This is Python developed with CPython.

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

Python software ==> python Interpreter (memory management)

Download:
Python3 is continuing to update
Python2 is continuing to update

Window: Dot
Python2
Python3
# Environment variables
With environment variable: C:\Program Files\Microsoft Games\solitaire
>>>solitaire

C:\Program Files\Microsoft Games\solitaire\solitaire


Linux:
Python2
Python3

A. Python basics
-Basic
1. The first sentence of Python
-the suffix name can be any?
-When importing a module, if it is not a. py file
==> after the file suffix name is. py

2. Two modes of execution
Python interpreter py file path
Python enters the interpreter:
Real-time input and get to execution results

3. Interpreter Path
#!/usr/bin/env python
4. Encoding
#-*-Coding:utf8-*-

Ascill 00000000

& 00000001


Unicode 0000000000000000+

& 0000000000000001
Medium 001000000000000111110010

How many utf-8 can be expressed by how many means
& 00000001
Medium 001000000000000111110010

Python3 no concern
Python2 each file appears in Chinese, the head must be added

5. Perform an action
Reminder user input: User and password
Get user name and password, detect: Username =root password =root
Correct: Login Successful
Error: Login failed

A. Use of input, wait forever until the user has entered a value, will assign the value of the input to a thing

6. Variable Name

-Alphabet
-Digital
-Underline
Ps:
Number cannot start
cannot be a keyword
It's best not to repeat the python built-in stuff.

name = "Stone Body"

7. Conditional statements
Indent with 4 spaces
A.
N1 = input (' >>> ')

If "alex" = = "Alex":
N2 = input (' >>> ')
if N2 = = "Confirm":
Print (' Alex SB ')
Else
Print (' Alex DB ')
Else
Print (' ERROR ')


Attention:
N1 = "Alex" Assignment
N1 = = ' Alex ' comparison,
B.

If condition 1:
Pass
Elif Condition 2:
Pass
Elif Condition 3:
Pass
Else
Pass

Print (' End ')

C. Conditions 1
And OR

if N1 = = "Alex" or N2 = = "Alex!23":
Print (' OK ')
Else
Print (' OK ')

Ps:
Pass generation means empty code, meaningless, just to represent a block of code

8. Basic data types

string-N1 = "Alex" n2 = ' root ' n3 = "" "Eric" "" N4= "' Tony '
Number-age=21 weight = fight = 5

Subtraction, etc.:
String:
Addition:
N1 = "Alex"
N2 = "SB"
N4 = "db"
N3 = n1 + n2 + N4
# "ALEXSBDB"

Multiplication:
N1 = "Alex"
N3 = N1 * 10
Digital:
N1 = 9
N2 = 2

N3 = n1 + N2
N3 = N1-n2
N3 = N1 * N2
N3 = n1/n2
N3 = n1% N2
N3 = N1 * * N2

Question:
11 12 13 ...

num = 12
n = num% 2
if n = = 0:
Print (' even ')
Else
Print (' odd ')

9. Cycle
Dead loop

While 1==1:
Print (' OK ')

10. Exercises if condition statement while loop odd even 1. Use while loop input 1 2 3 4 5 6 8 9 10N= 1 whileN < 11:                        ifn = = 7:                            Pass                        Else:                            Print(n) n= n + 1Print('----End----')                                    2, 1-100 of all the numbers and N= 1s=0 whileN < 101: S= S +N N= n + 1Print(s)3, Output 1-100all the odd n inside= 1 whileN < 101: Temp= n% 2iftemp = =0:Pass                        Else:                            Print(n) n= n + 1Print('----End----')                                        4, Output 1-100all even n in the= 1 whileN < 101: Temp= n% 2iftemp = =0:Print(n)Else:                            PassN= n + 1Print('----End----')                5. Seeking 1-2+3-4+5 ... 99 of all the numbers and N= 1s= 0#S is the sum of all the previous numbers                     whileN < 100: Temp= n% 2iftemp = =0:s= S-NElse: S= S +N N= n + 1Print(s)

6.
Request a blog
Organize today's content
User Login (three chance retry)

-Basic data types
-function
-Object Oriented

B. Network programming

C. Web Framework
-For writing websites

D. Design pattern + algorithm

E. Project phase

python-Basic Introduction

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.