Python3.X full stack-Day09-Python language introduction, variables, basic data types and while loops

  • 01 python full stack s3 day9 Python development series course outline
  • 02 python full stack s3 day9 Python homework requirements and blog
  • 03 python full stack s3 day9 programming language introduction
  • 04 python full stack s3 day9 introduction to Python types
  • 05 python full stack s3 day9 Python installation and operation of environment variables (1)
  • 06 python full stack s3 day9 Python installation and operation of environment variables (2)
  • 07 python full stack s3 day9 Python conditional statements and basic data types (1)
  • 08python full stack s3 day9 Python conditional statements and basic data types (2)
  • 09 python full stack s3 day9 Python first acquaintance and variables
  • 10 python full stack s3 day9 Python conditional statements and basic data types (this section has no sound due to device recording problems)
  • 11 python full stack s3 day9 Python while loop statement and practice questions
  • 12 python full stack s3 day9 practice questions explanation

01 python full stack s3 day9 Python development series course outline

1. Although Linux foundation and network foundation are not necessary skills for development, the full stack is the future development trend, and the basic operating principles should be familiar with;

2. Python development course;

1) Python foundation; (the foundation is not firm, the ground is shaking)

2) Network programming (sodcket, such as developing QQ, Wechat)

3) Resume upload from a breakpoint (such as Thunderbolt to download ISO image);

4) Web framework (commonly speaking, used to write websites);

5) Design patterns + algorithms (design is greater than coding)

6) The actual combat stage of the project (the stage of writing the essay)

02 python full stack s3 day9 Python homework requirements and blog

1. Basic, basic data types, functions, object-oriented programming

2. Blog reference: http://www.cnblogs.com/wupeiqi/articles/5433893.html  Mr. Wu Peiqi's Blog;

3. Homework: a. program; b. blog address (purpose, organizing the content of the blog is the process of thinking about yourself), recommendation: www.cnblog.com

4. Categories in the blog garden: Essays (any visible); Articles (invisible directly, you can send a URL to share and see); Diaries (as much as you can see);

03 python full stack s3 day9 programming language introduction

1. to develop this matter;

1) Mainly learn how to develop application software running on OS, such as QQ, Netease Cloud Music, and website;

2. Introduction to mainstream programming languages;

1)Python

  Python is an excellent comprehensive language. The purpose of Python is: simplicity, elegance, and clarity. It is widely used in artificial intelligence, cloud computing, financial analysis, big data development, web development, automated operation and maintenance, and automated testing. It is the 4th most procedural language in the world;  

2)Java

  Java is an object-oriented programming language that can write "cross-platform" application software. Java technology has excellent versatility, efficiency, platform portability and security, and is widely used in personal PCs, data centers, game consoles, scientific supercomputers, mobile phones and the Internet, and has the world's largest professional developer community. In the industrial environment of global cloud computing and mobile Internet, Java has significant advantages and broad prospects.

3)PHP

  PHP (foreign name: PHP-Hypertext Preprocessor, Chinese name: "Hypertext Preprocessor") is a general open source scripting language. The grammar absorbs the characteristics of C language, Java and Perl, which is good for learning and widely used.  

4)C#

5)C++

6)Ruby

7)Go

8) Summary:

  a. Machine language - the lowest level of advantage, the fastest speed, the disadvantage is the most complex, the lowest development efficiency; (generate machine code)

  b. Assembly language - the advantage is that it is relatively low-level, the fastest, and the disadvantage is that it is complex and has the lowest development efficiency; (generate machine code)

  c. High-level language - the compiled type has the fastest execution speed, does not depend on the language environment to run, and is inferior to cross-platform; the interpreted type is good for cross-platform, one code, runs everywhere, but the disadvantage is that the execution speed is slow, and it depends on the interpreter or virtual machine to run; (generates bytecode)

  d. Python has low execution efficiency and high development efficiency, but now the machine running speed follows Moore's Law;

  e. Java has high execution efficiency and lower development efficiency than Python;

9) Machine code and bytecode

  a. The machine code is 01010111 that the computer can directly identify;

  b. The byte code is first converted into byte code, and then converted again to machine code, and then the computer can recognize it; 

3. If programmers want to go far, they must learn the low-level language C language, so as to understand its operation principle;

04 python full stack s3 day9 introduction to Python types

1. We now know that Python is an interpreter. If the code wants to run, it must be executed through the interpreter. The Python interpreter itself can also be regarded as a program (that is, it doesn’t matter which country the translator is from), what language is this program developed in? The answer is in several languages.

1)Cpython

2)Jython

3) Pypy (Python developed by Cpython), although it is very fast, it is not mainstream and its functions are not yet stable.

4)IPython

5)IronPython

TIOBE releases April programming language rankings

http://www.mnw.cn/keji/internet/1970809.html

05 python full stack s3 day9 Python installation and operation of environment variables (1)

1. Install the Python interpreter

1) Python official website: https://www.python.org/

2) Python is installed on the operating system, we write the program according to the Python rules, hand it over to the Python software, read the content in the file, then convert and execute it, and finally get the result;

3) Installation of the Python interpreter (recommended to install both Python2.7 and Python3.5.3)

https://www.python.org/ftp/python/3.6.5/python-3.6.5-amd64.exe

4. Test whether the installation is successful: Windows-"Run-"cmd-"Enter Python, how to enter the interactive environment, indicating that the installation is successful;

5. Configure environment variables;

06 python full stack s3 day9 Python installation and operation of environment variables (2)

1. The directory structure of the Python interpreter

2. Configure the environment variable Path to easily execute the Python interpreter (note the English semicolon at the end);

Environment variables generally refer to some parameters used in the operating system to specify the operating environment of the operating system, such as the location of the temporary folder and the location of the system folder .
An environment variable is an object with a specific name in the operating system that contains information to be used by one or more applications . For example, the path environment variable in Windows and DOS operating systems, when the system is required to run a program without telling it the full path where the program is located, the system should not only look for the program in the current directory, but also look for the path specified in path. . Users can run processes better by setting environment variables .

3. Install two versions, modify python.exe and pythonw.exe to: python2.exe and pythonw2.exe and python3.exe and pythonw3.exe are used to distinguish different python versions;

07 python full stack s3 day9 Python conditional statements and basic data types (1)

1. if~else conditional statement;

#!/usr/bin/env python
# -*- coding:utf8 -*-
true_name = "tqtl"
true_password = "Ab123456" 

guess_name = input( " Please enter username: " )
guess_password = input( " Please enter your password: " )
 if guess_name == true_name and guess_password == true_password:
     print ( "The username and password are correct, welcome to Tiansunlang Mall. " )
 else :
     print ( "The username or password is incorrect, Please re-enter. " )

1) code block;

2) Python distinguishes code blocks strictly according to indentation;

3) The indentation of code blocks must be consistent, and the official recommendation is to indent 4 spaces;

4) Programs in Python are executed sequentially from top to bottom;

5) Nested execution order of if statements;

2. If~elif~else conditional statement:

vip_level = input( " Please enter the membership level: " )
 if vip_level == " level 1 member " :
     print ( " A beauty " )
 elif vip_level == " level 2 member " :
     print ( " B beauty " )
 elif vip_level == " level 3 member " :
     print ( " C beauty " )
 elif vip_level == " level 4 member ":
     print ( " D Beauty" )
 else :
     print ( " Whatever! " )
 print ( " Start enjoying the service! " )

1) The program is executed from top to bottom, print as long as the conditions are met, otherwise execute the next judgment;

2) Strictly pay attention to the English colon and indentation after the condition

3) Nesting can support multiple layers;

3. Supplement of if~else;

1  if condition is satisfied:
 2      pass 
3  else :
 4      print ( " xxxx " )

08python full stack s3 day9 Python conditional statements and basic data types (2)

09 python full stack s3 day9 Python first acquaintance and variables

1. print("Hello World!") Hello, world!

2. Although the Python suffix name can be arbitrary, an error will be reported when importing a module, so it must be written as a file ending with .py;

3. Two ways to execute Python code;

1) Python interpreter py file path;

2) Enter code execution directly in the python interpreter;

4. #!/usr/bin/env python and # -*- coding:utf8 -*- explanation

1) The file must be added under Linux; role: declare the python interpreter

2) Windows does not require #!/usr/bin/env python;

3)# -*- coding:utf8 -*- is required by Python2.x, but not required by Python3.x, because the default encoding method of Python2.X is ASCII, and the default encoding format of Python3.x is UTF-8

5. Write user login program

1) Remind the user to enter the username and password;

2) After obtaining the username and password, compare: username=root, password=root;

3) If it is correct, it indicates that the login is successful; if it is wrong, it indicates that the login fails;

6. The introduction of variables (the intermediate results of the program operation are temporarily loaded into the memory for the subsequent code to continue to call, the scientific names of these names are called "variables");

1) Variable names can only be any combination of letters, numbers and underscores (cannot start with numbers);

2)Python中关键字不能声明为变量[‘and','as','assert','break','claa','continue','def','del','elif','else','except','exec','finaly','for','from','global','if','import','in','is','lambda','not','or','pass','print','raise','return','try','while','with','yield']

3) The variable name needs to "see the name and know the meaning", such as name, age, sex, come_from, hobby;

4) Variable names are strictly case-sensitive, for example, name and NAME are two different variables;

5) How to define variables

  a. CamelCase: ageOfTqtl=26; numberOfStudents=1000

  b. Underline: age_of_tqtl=26;number_of_students=1000 (official recommendation, personal recommendation)

6) Modification of variables:

  a. The variable name is Chinese, pinyin (LOW) xinming="cuixiaozhao", nianling=26

  b. The variable name is too long: for example, where_are_you_from = "hebei"

  c. The variable noun does not convey its meaning: for example, fdjskfkldasfd=25 (even the gods can’t understand it)

7) Definition of variables

  name = "Cuixiaozhao"

The left side is the "variable name", and the right side of the equal sign is the "variable value";

10 python full stack s3 day9 Python conditional statements and basic data types

1. String

1) All quoted characters in Python are considered "strings" - single quotes, double quotes, three single quotes, and three double quotes are all strings

1 name = 'cuixiaozhao'
2 name = "cuixiaoshan"
3 name = '''cuixiaosi'''
4 name = """cuixiaolei"""

2) Concatenation of strings (addition)

1 name = "cuixiaozhao"
2 name_alias = "_tqtl"
3 names = name + name_alias
4 print(names)#cuixiaozhao_tqtl

3) Multiplication of strings

name = "_tqltl"
names = name * 10
print(names)
_tqltl_tqltl_tqltl_tqltl_tqltl_tqltl_tqltl_tqltl_tqltl_tqltl

11 python full stack s3 day9 Python while loop statement and practice questions

12 python full stack s3 day9 practice questions explanation

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325067264&siteId=291194637