Basic Python Learning--the first play

Source: Internet
Author: User
Tags php class

Advanced language--------> Bytecode----------> Machine code

Low-level language--------> machine code

Performance: Advanced < low level

High-level language automatic garbage disposal mechanism, convenient, development efficiency.

PHP class: Quickly build a website, suitable for writing web pages, there are limitations.

Python/c/java: Artificial Intelligence.

Python/java: Can write the page, but also can write the background function.

Java executes more efficiently than Python,java can do, Python can do it, and development is more efficient.

The database is the culprit for program execution speed.

Python type:

Jpython

IronPython

Cpython

Javascriptpython

.........

CPython high efficiency, mainstream.

PyPy: This is Python developed with CPython, the first execution is slow, the bytecode needs to be generated, and soon thereafter. Executes faster than CPython.

Can the Python file suffix be arbitrary? When importing a module, there may be an error if it is not. py.

Interpreter Path:

#!/usr/bin/env Python used in------>linux

Coding:

The program contains Chinese, Python2 cannot execute, Python3 can.

-----> Coding issues.

Python2 default encoding using ASCII code, you can add #-*-Coding:utf8 at the top of Python2 program-*-

ASCII 00000000

Unicode 0000000000000000+ may waste memory

Utf-8 can use how many digits to express (perfect AH!!! )

Python3 no need to pay attention

Python2 contains Chinese, the head must be added

To 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

# -*-Coding:utf8-*- # wait forever until the user enters a value that will assign the input value to n,n refers to what the user entered n1 = input (")    = input ('  ')print (  N1)print (n2)                                                     

Single-line Comment: #

Multiline Comment: "" "Content" "" three quotation marks

Basic data type:

String: "abc", ' abc ', "" "" abc "" "," ABC "

Algorithm: N1 = "I", N2 = "Love", N3 = "You"

N4 = n1 + N2 + N3 addition

N5 = n3 * 7 multiplication

Number: Age = 13

Algorithm: a1 = A2 = 20

a3 = A1 + A2

A3 = A1-a2

a3 = A1 * A2

A3 = A1/a2

a3 = 4 * * 2 (4 squared) 3**4 (3 4-Time Square)

A3 = 39 8=7 (Gets the remainder by 39 divided by 8)

A3 = 39//8 = 4 Pick-up

Judging parity:

A = 2= a%if temp = = 0:  print(" even ")else< /c8>:  print(" odd ")

Cycle:

Dead Loop:

 While 1 = = 1:  print("OK")

Modify the execution:

Import= 0 while Count <:    print("OK " , Time.time ())     = count + 1print(123)

Using while loop input 1 2 3 4 5 6 8 9 10:

Count = 0 while Count <=10:    if count! =7        :  Print(count)    = count + 1

The and of all numbers of 1-100:

Count = 1= 0 while Count <=:    = s + count    = count + 1print
     (s)

All odd numbers within the output 1-100:

Count = 1 while Count <=:    if count% 2! = 0:        Print( Count,"---> Odd ")    = count + 1

Find out all the numbers of 1-2+3-4+5....99 and:

Count = 1= 0 while Count <:    if count% 2! = 0:        = s +
   
     Count    
    else
    :        = S-
     count    = count + 1
    print (s)
   

User Login (three chance retry):

Count = 1name="Root"Psword="12345"N= Input ("Please enter user name:") P= Input ("Please enter your password:") whileCount < 3:    ifn! =name:n= Input ("user name is wrong, please re-enter the user name:")    ifP! =psword:p= Input ("password is wrong, please re-enter the password:")    Else:        Print("Login Successful")         BreakCount= Count + 1ifCount >= 3:        Print("error more than three times, please try again tomorrow")

   

Basic Python Learning--the first play

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.