1. Simple classification of programming languages
The earliest machine language in advanced languages
Assembly
Advanced languages: C language, Python, Java, C + +, C #, Object-c
What kind of language is 2.python?
Compiled, interpreted, static, dynamic, strongly-typed, and weakly-type-defined languages.
Differences in compilation and interpretation: Using different methods
Explanatory: script Run
Naming conventions for 3.python variables
(1) can only be letters, numbers, underline composition
(2) cannot start with numbers or all numbers (mandatory)
(3) cannot be a python keyword (def if while)
(4) Do not use Chinese
(5) Not too long
(6) Try to make sense
(7) Recommended use of camel body: Capitalize the first letter of the word
Underline: Words are separated by underscores
(8) Case-sensitive
4. Data type (initial)
In Python, each variable is of a type
(1) integer (int).
(2) string (str).
Character: a single text symbol you can see
String: A bunch of characters arranged in a fixed order
With ', ', ' ', ' '.
Note: print ("") #空字符串
Print ("") #空格字符串
(3) Boolean (bool) pairs and wrongs, true and false true false
The type (variable) tells you what the variable is.
5. User interaction Input(prompt). Will be returned to you to enter the content
Input ("Please enter your name:")
S= "I'm named name, 18 years old this year."
Print (s)
A=input ("Please enter a:")
B=input ("Please enter B:")
Converts a string into an int
int (str)
C=int (a)
D=int (b)
Print (C+D)
constant immutable variable
There is no absolute constant in Python. We have a conventional. All the variable letters are in uppercase and constant.
Print Statements
Print ("12", "13")
6. Conditional Judgment
if: if
Else: Otherwise, the content that is executed when the condition is not established
(1) If condition:
code block
Else condition:
code block
(2) If condition:
code block
Elif Conditions:
code block
Elif ...
Else
7. Syntax:
While condition:
code block
Description: Determine if the condition is true. If true, execute the block of code (the loop body) and continue to determine whether the condition is true after execution. If it does, continue. Until the condition is false stop.
(1) Number of questions
Index=1
While index<101:
Print (index)
Index=index+1
(2) 1+2+3+4+...+100=?
Index=1
Sum=0
While index<101:
Sum=sum+index
Index=index+1
Print (sum)
Break: Stops the loop. Completely stop a loop (stop the current layer loop)
Continue: Stop this cycle. Continue with the next loop
(1)
Index=1
While index<101:
Print (index)
Index=index+1
If index==88:
Break
(2)
Index=1
While index<101:
If index==88:
Index=index+1
Continue
Print (index)
Index=index+1
Python learning content. 01