Coding
In the Linux system or Python2 version to use the Python language, you need to add in the beginning
# -*-Coding:utf8-*-
The statement is that when the machine compiles the program you write it is compiled in the form of utf-8 encoding.
If not added, it will be garbled when output Chinese with print
The specific reason to start from the knowledge of coding:
Because computers can only recognize 0 and 12 digits, the characters that the computer stores are made up of a large number of 0 and 1 numbers. The rules for storing these numbers are first ascill yards.
But the ASCII code compiles only 8 bits of capacity, and then people invented Unicode. It compiles 16 bits, which means it can store more than 0 and 1 of the different combinations, which means it can compile more characters, but the problem is, assuming that the Asciil code for A is 00000001, if it's Unicode Compilation is a Unicode code of 000000000000001. See, so many 0, you do not go to calculate, estimate when the head eyes are Dim! , so many 0 is better to use ASCII code to compile, and super waste memory!
Thus people invented the Uft-8 code, which can store at least 8 bits of 0 and 1, at least!!!! That is, when he stores a, the compilation is 00000001, he can store up to 4 bytes of character 8 bits, that is, he can store up to 32 bits, when he stored Chinese, he will automatically expand the 16-bit 24-bit 32-bit, thus saving a lot of memory space.
Python's power
To turn Python is so powerful, I can only say hahaha python is really the best language in history! I must learn python!. Because it is too convenient!
n = input (' Are you a member of the first club ') if n = = ' is ' print (' Welcome ') '
As in the example above, input ("string"), input will first output the "string", and then the user input data into the variable N.
Another look at the IF statement Python's if statement can also determine if the strings are equal.
Python Basic data type focus
n = 4**4 #计算4的4次方
n = 39/4 # Calculates 39 divided by 4 quotient with decimals
N =394//4 #计算39除以4的商不带小数
If and while
Today I learned about Python's if statement conditions and loops
The IF format is
If condition:
Statement
Else
Statement
also have
If condition:
Statement
Elif Conditions:
Statement
If 1==1: passelse: print (' SB ')
If the above statement does not want to perform any action when 1=1 to use pass.
Whlie Cycle
To add 1 to 100, we are going to use loops. Now that we've only learned while, let's talk about Wihile.
A = 1b = 0while a<101: B = B + a a = a +1print (b)
Write Whlie when the condition is true on the loop, for the false exit loop. This cumulative problem, we need to calculate the number of cycles 1 accumulated to 100 need to cycle 100 times, remember when we played the snake of gluttony, hey! I think the accumulation of a bulimia snake is more and more long (big) ha, since there is food a that must have a snake B ah, that is, variable B, let him in each cycle condition to eat a, once accumulation, and a also in the accumulation, not up to the cycle conditions to exit.
The first day to end here, I hope that I can continue to study, Woo-hoo ~ Although the school a lot of courses hope to be able to fill it back.
I hope I can learn something!
The basics of coding and Python