Python3- basic exercises

1. are two ways to execute Python scripts

 

 

 

2. Description of the relationship between bits, bytes

 

 

 

3. Description of Relationship ascii, unicode, utf-8, gbk of

 

 

4. Please write digit "Jie" respectively utf-8 encoded and occupied gbk

 

 

 

5.Pyhton single-line and multi-line were what?

 

 

 

6. Affirms term variable pay attention to what?

 

 

7. If the next variable n1 = 5, using the methods provided int obtain the minimum number of variable bits can be expressed by?

 

 

 

8. What are the Boolean value?

 

 

9. read the code, please write the results

1 a = "alex"
2 b = a.capitalize()
3 print(a)
4 print(b)

Please write the output:

 

 

 

10. The write code, the following variables, as required to implement each function

1 name = ”aleX“

a. Remove the variable name corresponding to the value of both sides of the space, and the input content after removal of the

 

 

b. determining whether the value of the corresponding variable name begins with "al", and outputs the result

 

 

c. determining whether the value corresponding to the variable name to "X" at the end, and outputs the result

 

 

 

d. Set the value of the variable name corresponds to the "l" is replaced with "p", and outputs the result.

 

 

 

e. Insert in accordance with a value corresponding to the variable name "l" division, and outputs the result

 

 

f. I ask, a question on the value of e obtained after the segmentation is what type (optional)?

 

 

 

g. the name corresponding to the variable value becomes capital, and outputs the result

 

 

 

h. Fold change values ​​corresponding to the variable name in lower case, and the output

 

 

 

i. Please output of the two character values ​​corresponding to the variable name?

 

 

 

j. Please output of the first three characters of the name value of the corresponding variable?

 

 

 

k. Please post the output value of two variables corresponding character name?

 

 

The value of l. Please variable name corresponding to the output "e" where the position of the index?

 

 

. M acquisition sequence, only the last character is not included, such as: oldboy is acquired oldbo; root is acquired roo

 

11. Does the string iterable? If available, use a for loop each element?

 

 

 

 

12. The use code implementation:

a. underscore using each element of the list spliced ​​into a string, li = "alexericrain"

 

 

 

b. Using underlined each element of the list assembled into a string li = [ "alex", "eric". "rain"]

 

 

 

 

13.Python2 the range and Python3 What is the difference

 

 

 

 

14. A calculator implemented an integer addition:

Such as: content = input ( "Please enter Content:") such as: 5 or 9-5 or 9 + 9 + 2

 

 

 

15. The calculation of the content entered by the user in a few decimal? Several letters?

Such as: content = input ( "Please enter the text:")

 

 

 

Relationship between 9 and 16. DESCRIPTION int str numbers and the like and "xxoo" like the string

 

 

 

 

17. make fun template program

Requirements: waiting for the user to enter the name, location, hobbies, arbitrarily implemented according to the user's name and preferences

Such as: Dear xx, users, like most places in the dry xx xxx.

 

 

 

18. Production of random codes, case insensitive

Process:

1. The user program execution

2. displayed to the user to enter the verification code.

3. The value entered by the user

And a value entered by the user is displayed simultaneously displayed correctly, otherwise continue to generate random codes continue to wait for user input

Generate the verification code Code Example:

 

 

 

 

 

19. The development of sensitive word filtering program prompts the user to enter content, if the content entered by the user contain special characters such as: "Cang teacher", "Tokyo hot", the content is replaced with ****

 

 

 

 

20. Create a table

Loop prompts the user: username, password, email (required length of the user input is not more than 20 characters, if more than only the first 20 characters are significant), or if a user enters q Q represents no longer continue to enter, the user input content output in tabular form

Guess you like

Origin www.cnblogs.com/tanxiaox/p/12089207.html