What is a computer
1 A computer is a machine made up of a bunch of hardware.
2 Classification of hardware:
CPU: Like a human brain, running a program that needs to run.
Memory: The contents of the CPU to be run from the hard disk read out, and then the CPU in memory to take the content, just a transient storage, add a sudden shutdown, the data will be lost.
Hard disk: Hard disk equivalent to a person's notebook, long-term can store data, permanent storage. The shutdown data is not lost.
The three of them are operated by the operating system.
3 What makes the operating system: the operating system itself is a software, and it is built on the hardware, he controls the operation of each hardware, is the hardware running orderly.
4 What is an application: The application is software, is built on the operating system, such as: QQ Iqiyi art, etc. belong to the application
5 The operational process between the hardware, the operating system and the application is that the application needs data, so when it starts, it communicates the instructions to the operating system, and then the operating system reads the required data from the hard disk into memory, then the CPU takes the data from the memory and executes it and communicates it to the operating system. The operating system is communicated to the application.
Introduction of two languages
Classification of languages: 1 Efficiency classification:
C Language: Fast execution, directly converts the code of human identification into machine code.
Java, C #, Python, PHP: the implementation is slightly slower, the implementation is to convert the code of human identification into bytecode, and then convert the bytecode into machine code.
2 explanatory and compile type
Compiled: C, Java, C # translate a bunch of code
Interpreted type: Python, PHP write a code, translate a sentence.
3 Easy to learn: Python: The code is simple, easy to understand, there is a powerful class library, full-featured
Other:
4 Why not learn C: complex, code-prone, and code-repeatable
5 Why not learn java,c#:c# Windows runs, Windows pays
Java: Learning is very difficult
6 Why not learn php:web development, preconceived
JavaScript, can only be used in conjunction with a variety of languages, to achieve the dynamic effect of Web pages.
Three Python introduction
Python Common environment: Web Development
Crawler development
Financial
Artificial intelligence
Python categories: CPython, Jpython,ironpython,rubypython,pypy .... A lot of sorts, but there's only one rule
Python versions are divided into 2.* and 3.* versions. Python's version is constantly being updated, and the 2 version features more and more close to the 3 version feature.
If Python needs to delete an older version of the feature, it will tell the programmer next to the update, so that the programmer can prepare for the next version of the update, and the next version will remove the feature
Because the Python language is powerful, the interpreter for other languages can execute Python code. The interpreter was written by the founder of the language, so we just write the code and the program.
Four-mount Python. Interpreter
The URL to download Python is: https://www.python.org
Download process: http://jingyan.baidu.com/article/08b6a591a0ee8c14a9092261.html
Installation process: http://jingyan.baidu.com/article/0bc808fc42dfab1bd485b99f.html
Five Add environment variables
1 Right click on the Start menu, then select System, enter system
2 Click Advanced System settings to enter
3 Click on the environment variable to enter
4 then select the Path variable and click Edit to enter edit
5 then the value of the variable is written to the relative path of the interpreter you want to add, and each environment variable is separated by a semicolon (;). then click Confirm.
6 Click on the confirmation in the environment variable to add the success
Six Python-based code
Print: Printing ("Miroslav") execution result is: Miroslav
Input: Smart input such as input (">>>:") execution result is >>>: can enter content
Seven variables
Variables are made up of variable names, assignments, and variable values such as: x=2
Variable names can be letters, numbers, and underscores, and numbers cannot be the first position such as: X_1=6 _y3=8
The variable name is best replaced by English, and is known as the name.
Type of variable value: String type: Quoted content
Integer type: A number that is not enclosed by quotation marks
Boolean type: Only two values of true and false.
Such as:
Age = 18 Integer type name = "Name Ruijie" String type gender = True/false Boolean type
Eight arithmetic symbols
Common comparison operators for numbers
= = Equals (because an equals sign is an assignment function, so the equals sign requires two) < less than sign > greater than sign <= less than equals sign >= greater than equals sign
result = = = 18result = < 18result = + > 18result = <= 18result = >= 18
The usual arithmetic symbols for numbers are
+ Plus-minus * multiply/divide%
result = 1 + 1result = 1-1result = 1 * 1result = 1/1
The budget symbol for a string is only two + plus and * multiply
A= "Fang" + "Jie" #执行结果fangjieb = "Jie" * 2 #执行结构jiejie
Nine if Judgment statement
Format 1: Single-branch if judgment: if judgment condition:
EXECUTE statement Format 2: Double if judgment: if Judgment statement:
EXECUTE statement
Else
EXECUTE statement
Format 3: Multi-branch if judgment: if Judgment statement:
EXECUTE statement
Elif
EXECUTE statement
Elif
EXECUTE statement
。。。。
Else
EXECUTE statement
Format 4:if: Nested IF Judgment statement:
EXECUTE statement
If Judgment statement
EXECUTE statement
Else
EXECUTE statement
Else
EXECUTE statement
#single-branch if judgmentif7<8: Print("That 's right.")#Double-branch if judgmentif7>8: Print('you're stupid .')Else: Print('That 's right.')#Multi-branch if judgmentif7>8: Print('you're stupid .')elif7==8: Print('you're so stupid .')Else: Print('That 's right.') #If judgment nestingName=input ('>>>:')ifname=='Fang': Password=input ('>>>:') ifpassword=="666": Print('Landing Success') Else: Print("Login Failed")Else: Print("wrong input")View Code
Ten while loop
Format 1:while Condition:
EXECUTE statement
Format 2:while Condition:
EXECUTE statement
Else
EXECUTE statement
The keyword in the while loop: Break jumps out of the current loop
Continue jump out of the loop and make the next loop
#Format 1 whileTrue:Print(2)##Format 2A=True whileA:Print(1) A=FalseElse: Print(2)# Break whileTrue:Print(4) Break #ContinueA=True whileA:Print(3) Continuea=FalseElse: Print(2)
View Code
#1. Print all the odd numbers between 1-99#a=1#While a<100:#if a%2==0:#a+=1#Else:#print (a)#a+=1#2. Print between 1-99 All can be divisible by 3 number#b=1#While b<100:#if b%3==0:#print (b)#b+=1#Else:#b+=1#3. Print the sum of all the numbers between 1-99#c=1#d=0#While c<100:#D+=c#c+=1#print (d)#4. Print all odd sums between 1-99#e=1#f=0#While e<100:#if e%2==0:#e+=1#Else:#f+=e#e+=1#print (f)#5. Print 1-2 + 3-4 + 5-6 + 7 ... + 99 all odd sums#g=1#h=0#While g<100:#if g%2==0:#h-=g#g+=1#Else:#h+=g#g+=1#print (h)
Exercises
Retake Course day1 (Python Foundation 1)