Python Full stack exam

Source: Internet
Author: User

1. Two ways to execute Python scripts

Terminal and interactive mode

Method 1:
Python helloword.py

2, briefly describe the relationship between bits and bytes  

1 Byte = 8 bit
1 bit = 1/8 Byte
1 bytes = 8 bits
1-bit =1/8 bytes

3. Brief description of the relationship between ASCII, Unicode, Utf-8, GBK

    • Unicode: Contains character encodings for all countries
    • Utf-8 variable long character encoding, English represents a byte, Chinese represents 3 bytes
    • ASCII American symbol Information Exchange code, is a set of computer coding system based on Latin alphabet, mainly used to display modern English and other Western European languages, one character for one byte
    • GBK full Name "Chinese character code extension code", one character occupies two bytes

4. Please write "Li Jie" the number of digits that are encoded by Utf-8 and GBK respectively.

    • In Utf-8, a Chinese character occupies 3 bytes
    • A Chinese character occupies 2 bytes in GBK
    • Li Jie = utf-8 (6 bytes) =48
    • Li Jie = gbk (4 bytes) =32

5, Pyhton single-line comments and multiline comments with what?

    • Single-line Comment #
    • Multi-line Comment ""

6. What are the considerations for declaring variables?

    • Variable names can only be any combination of letters, numbers, or underscores
    • The first character of a variable name cannot be a number
    • The following keywords cannot be declared as variable names
    • [' and ', ' as ', ' assert ', ' Break ', ' class ', ' Continue ', ' Def ', ' del ', ' elif ', ' Else ', ' except ', ' exec ', ' finally ', ' for ', ' F ' Rom ', ' Global ', ' if ', ' import ', ' in ', ' was ', ' lambda ', ' not ', ' or ', ' pass ', ' print ', ' raise ', ' return ', ' try ', ' while ', ' WI Th ', ' yield ']

8. How do I see the address of a variable in memory?

9. What is the purpose of the automatically generated. pyc file when executing a Python program?

10. Write code
A. Implement user input user name and password, when the user name is seven and the password is 123, the display login is successful, otherwise the login failed!

Name = input ("name") passwd = input ("passwd") if (name = = "Seven" and passwd = = "123"):    print ("login Successful") Else:    print (" Login Failed ")

B. Implement user input user name and password, when the user name is seven and the password is 123, the display login is successful, otherwise the login failed, the failure to allow repeated input three times

C. Implement user input user name and password, when the user name is seven or Alex and the password is 123, the display login is successful, otherwise the login failed, the failure to allow repeated input three times

11. Write code
A. Using a while loop to implement output 2-3+4-5+6...+100 and
B. Using the For loop and range for output 1-2+3-4+5-6...+99 and
C. Use the while loop to implement output 1,2,3,4,5, 7,8,9, 11,12d. Use the while loop to implement all the odd numbers in output 1-100
E. Using a while loop to implement all the even numbers in output 1-100

12, the binary representation of the digital 5,10,32,7 is written separately

13. Brief description of the relationship between the object and the class (using figurative methods)

14, the existing following two variables, please briefly describe N1 and N2 what is the relationship? n1 = 123

N2 = 123

15, the existing following two variables, please briefly describe N1 and N2 what is the relationship? n1 = 123456

N2 = 123456

16, the existing following two variables, please briefly describe N1 and N2 what is the relationship? n1 = 123456

N2 = N1
17, if there is a variable n1 = 5, use the provided method of int, how many bits can be used to get the variable at least?

18, what are the Boolean values respectively?

19, read the code, please write the results of the implementation

A = "Alex"
b = A.capitalize () print (a)
Print (b)

Please write out the results:

20, write code, there are the following variables, please follow the requirements of the implementation of each function name = "AleX"

A. Remove the space on both sides of the value corresponding to the name variable and enter the removal of the content B. Determine if the value corresponding to the name variable starts with "Al" and outputs the result
C. Determine if the value corresponding to 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. The value corresponding to the name variable is split according to "L" and the result is output.

F. What type of value is obtained after the e-partition of the previous question? G. Capitalize the value corresponding to the name variable and output the result
H. Lowercase the value corresponding to the name variable and output the result
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 first 2 characters of the value corresponding to the name variable?
L. Please output the value of the name variable corresponding to the index where "E" is located?

21, can the string be iterated? If you can use the for loop for each element? 22. Use the underscore code to stitch each element of the list into a string, Li = [' Alex ', ' Eric ', ' Rain ']22, write code, like the following list, to implement each function as required

Li = [' Alex ', ' Eric ', ' Rain ']
A. Calculate the length of the list and output
B. Append the element "seven" to the list and output the added list
C. Insert the element "Tony" in the 1th position of the list and output the added list
D. Please modify the element in the 2nd position of the list to "Kelly" and output the modified list
E. Remove the Element "Eric" from the list and output the modified list
F. Delete the 2nd element in the list and output the value of the deleted element and the list after deleting the element G. Delete the 3rd element in the list and output the list after the element is deleted
H. Delete the 2nd to 4th element in the list and output the list after the element is deleted
I. Invert all the elements in the list and output the inverted list

J. Use the index of the for, Len, range output list
K. Use the Enumrate output list element and ordinal (ordinal starting from 100) L. Use the For loop to output all elements of the list

23, write code, such as the following table, please follow the functional requirements to achieve each function Li = ["Hello", ' Seven ', ["Mon", ["H", "Kelly"], ' all '], 123, 446]a. Please output "Kelly"
B. Please use the index to find the ' all ' element and modify it to "all"

24, write code, there are the following tuple, according to the requirements of the implementation of each function Tu = (' Alex ', ' Eric ', ' Rain ')
A. Calculating the tuple length and outputting
B. Gets the 2nd element of a tuple and outputs

C. Get the 第1-2个 element of the tuple and output

D. Use the element for the for output tuple
E. Use the index of the for, Len, and range output tuples
F. Use the Enumrate output element ancestor elements and ordinal number (ordinal starting from 10)

25, there are the following variables, please implement the required functions
Tu = ("Alex", [One, one, a, {"K1": ' V1 ', "K2": ["Age", "name"], "K3": (11,22,33)}, 44])

A. Describing the characteristics of Ganso
B. Can you tell me if the first element in the TU variable, "Alex", could be modified?
C. What is the value of the "K2" in the TU variable? Can it be modified? If you can, add an element "Seven" D. What is the value of the "K3" in the TU variable? Can I modify it? If so, add an element "Seven" to it.

26. Dictionaries
DiC = {' K1 ': "v1", "K2": "V2", "K3": [11,22,33]}

A. Please loop out all the keyb. Please loop out all of the value

C. Please loop out all the keys and value
D. Add a key-value pair in the dictionary, "K4": "V4", and output the added dictionary
E. In the modified dictionary, the value of "K1" corresponds to "Alex", Output the modified dictionary F. Please append an element 44 to the value of the K3 to output the modified dictionary
G. Insert element 18 in the 1th position of the K3 corresponding value, output the modified dictionary

27. Conversion
A. Converting a string s = "Alex" to a list
B. Convert the string s = "Alex" to Cheng Yuanju
B. Convert the list li = ["Alex", "seven"] to the Narimoto group
C. Convert meta-progenitor tu = (' Alex ', ' seven ') to a list
D. Convert the list li = ["Alex", "seven"] to a dictionary and the dictionary key is incremented by 10

27. transcoding

n = "Old boy"
A. Convert the string to UTF-8 encoded byte and output, then convert the byte to Utf-8 encoded string, and then output a. Converts a string into a GBK encoded byte, outputs it, and then converts the byte to a GBK encoded string, and then outputs

28. For all numbers within 1-100

29. Element classification
There is a value set [11,22,33,44,55,66,77,88,99,90] that holds all values greater than 66 to the first key in the dictionary, and a value less than 66 to the value of the second key.

That is: {' K1 ': All values greater than 66, ' K2 ': All values less than 66}

30, Shopping cart function requirements:

Require the user to enter total assets, for example: 2000 display a list of items, let the user select items according to the serial number, add shopping cart purchase, if the total amount of goods is greater than the total assets, the account balance is insufficient, otherwise, the purchase success.

goods = [
{"Name": "Computer", "Price": 1999},

{"Name": "Mouse", "Price": 10},{"name": "Yacht", "Price": 20},{"name": "Beauty", "Price": 998},

]

Python Full stack exam

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.