Self-taught Python first time finishing

Source: Internet
Author: User

First, learn the history of Python and some nouns

Explanatory language: Side compilation Edge execution

Compiled language: first compiled and executed such as C,python

Dynamic languages: No need to declare variable types, Eg:python Ruby

Static language: Variable types need to be declared

Strongly typed languages: Once you define a type, you must undergo a forced conversion to become another type of Python

Weakly typed languages: Data types can be ignored

Second, the advantages of Python

Simple, efficient, high-level language, portability, extensibility, embeddable

Disadvantages:

Slow, non-encrypted, multi-threaded (Pypy,ps:pypy is Python's fastest IDE if you want the code to be fast)

Third, variable

Ageofoldboy =    #驼峰表示法 age_of_oldboy =  #一般的方法 age_of_oldboy =  #这个是代表着常量 Letters all uppercase nominally represent constants but are essentially variables

(1), variable cannot start with a number

(2), cannot be interspersed with special characters

(3), can not be the key in order to give the variable name

Four, character code

ASCLL (1B)--gb2312 (7,000 multi-kanji)-GBK (supports 2w+ kanji)-gb18030 (2.7w+ kanji)

Final to unified encoded Unicode (16-bit)

UTF8 English 1B Chinese 3B

(Python 2 needs to define UTF-8 characters and Python 3 doesn't need to define Chinese character encodings)

Five, the Code

    • Comments
      Single-line Comment #代码
      Multi-line Comment ' code '
    • %s placeholder

# . Formatname = input ("name  :") Age = Input ("Age: ")   # int (Input ("Age:"))Job  = input ("job:" " -------info of {na}---------Name: {na}age:  {ag}job:  '. Format (na=name,ag=age,jo=job)print(Info2)

1Name = input ("Name:")2Age = Input ("Age :")#int (Input ("Age:"))3Job = input ("Job:")4info =" "5 --------Info of%s-----6 name:%s7 age:%s8 job:%s9  " "%(name, name, age, Job)Ten Print(info)
    • Import imports the standard library
    • The individual code must be shelf written
    • While if break (understand the purpose of the last else PS: when there is no execution result on the top while the else below is executed)
_username ="SGS"_password="121"Count=0 whileCount<3: Username= Input ("Username:") Password= Input ("Password:")    if_username==username and_password==Password:Print("Welcome you!")         Break    Else:        Print("Username or PASSWRD was error") Count+=1Else:    Print("User lock!")
    • In parentheses (starting value, terminating value, step size)
 for  in range (0,10,2):    if i<3:        print(i)      else  :        continue    print("hehe")
    • Understand the meaning of break and Continue: Break is the end of the current loop, Continue end this cycle into the next loop!

  

Self-taught Python first time finishing

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.