1, two ways to execute a python script
First, configure the environment variable, find the Pyhon file, in the form of: Python 1.py
Second, enter the interpreter, the real time input output, the form: Python
In Linux, adding the statement inside the file #!/usr/bin/env python, the interpreter's location, the terminal execution file./1.py.
2, a brief description of the relationship between bits and bytes
A byte 8-bit, calculated in bytes by the computer, and stored in bits.
3, briefly on the relationship of Ascii,unicode,utf-8
The first occurrence is ASCII encoding, followed by Unicode encoding, and, because of the different standards in each country, the compression encoding utf-8 of Unicode occurs. ASCII code 8 bits, Unicode code 16 bits. ASCII code characters, and then the Unicode representation will cause memory waste, the proposed UTF-8 encoding, can be expressed as much as the number of representations.
4, please write "Lijie" the number of bytes used utf-8 and GDK encoding respectively
Utf-8: One Chinese 3 bytes, the Chinese is 6 bytes
GDK: One Chinese 2 bytes, the Chinese is 4 bytes
A = "Lijie"
#python3中, the number of characters is calculated
Len (a) = 2
For item in a:
Print (item)
#python2中, the number of bytes is calculated
Len (a) = 6
For item in a:
Print (item)
5,python What to use for Single-line and multiline comments.
Single-line Comment: # (shortcut key CTRL/)
Multiline Comment: "" "" "," ""
6, declare the variables note there are.
Numbers, underscores, letters, numbers cannot begin, and must not repeat with keyword names. Try not to use Python's built-in function name, and you may get an error.
7, if there is a variable n1=5, please use the method provided by int to get the minimum number of bits that the variable can be expressed.
Function: Bit_length ()
8, what is the Boolean value respectively.
True False
9, read the code, please write the results of the implementation
A = "Alex"
b =a.capitalize ()
Print (a)
Print (b)
Please write out the output:
10, write code, there are the following variables, please follow the requirements to achieve each function
Name= "AleX."
A. Remove the spaces on both sides of the value for the name variable and enter the removed content
B. Determine if the value of the name variable starts with "Al" and outputs the result
C. Determine whether the value of the name variable ends with "X" and outputs the result
D. Replace the "L" in the value corresponding to the name variable with "p" and output the result
E. Split the value corresponding to the name variable according to "L" and output
F. What is the type of the value (optional) After the last question E split?
G. Capitalize the value of the name variable and output the result
H. Change the value of the name variable to lowercase and output the knot
I. Please output the 2nd character of the value corresponding to the name variable.
J. Please output the first 3 characters of the value corresponding to the name variable.
K. Please output the latter 2 characters of the value corresponding to the name variable.
L. Please output the index where "E" is located in the value corresponding to the name variable.
M. Gets the subsequence and does not contain the last character. such as: Oldboy is to obtain oldbo; Root gets the roo
11. Whether the string can iterate over the object. Use a For loop for each element, if possible.
The iterated object = = = = can be obtained with the For loop.
For I in string:
Print (i)
12, please use code to achieve:
Use underscores to concatenate each element of a list into a string, li= "Alexericrain"
13, Python2 in the range and Python3 in the difference.
The iterated object = = = = can be obtained with the For loop
Python2: Create Now
Range (100), print 0-99, memory is allocated once.
Python3:range is only created one at a time in the loop.
Print 0-99 code as follows:
For I InRange (0,100,5):
Print (i)
This is the Python3 optimization mechanism, which is created only in the For Loop Zhongcai, and saves memory, containing the garbage collection mechanism.
14. Implement an integer addition calculator:
such as: ontent= input (' Please input: ') #如: 5+9 or 5+9 or 5+9
15, the user input to calculate the content of a few decimal decimals. Few letters.
such as: content= input (' Please input: ') #如: asduiaf878123jkjsfd-213928
16. Briefly describe the relationship between int and 9 and other strings such as STR and "Xxoo".
Relationships between classes and objects