Python full stack exam (i)

Source: Internet
Author: User

1. two ways to execute Python scripts

2, briefly describe the relationship between bits and bytes

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

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

5, Pyhton single-line comments and multiline comments with what?
6. What are the considerations for declaring variables?
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!

Import getpassname_login=input ("Please enter your user name:") PSW = Getpass.getpass ("Please enter your password:") if Name_login = = "Seven" and PSW = = "123": C10/>print ("Landing success!") 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

Count = 0import Getpasswhile Count < 3:    name = input ("Please enter your user name:")    psd = Getpass.getpass ("Please enter your password:")    if Name = = "Seven" and psd== "123":        print ("Login successful! Break    Else:        print ("Login failed!") ")    Count +=123

   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

Count = 0import Getpasswhile Count < 3:    name = input ("Please enter your user name:")    psd = Getpass.getpass ("Please enter your password:")    if ((name = = "Seven" or name = = "Alex") and PSD = = "123"):        print ("Welcome seven user!")        Break    Else:        print ("Login failed!")        Count +=1

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. Using a while loop to implement output 1,2,3,4,5, 7,8,9, 11,12 D. Using a 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 what the relationship between N1 and n2? n1 = 123 N2 = 123
15, the existing following two variables, please briefly describe what the relationship between N1 and n2? n1 = 123456 N2 = 123456

16, the existing following two variables, please briefly describe what the relationship between N1 and N2? 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 of the name variable and enter the removed content B. Determine whether the value of 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 e-segmentation 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 strings be iterated? If possible, use the for loop for each element? 22, please use the code to achieve: the use of underscores each element of the list into a string, Li = [' Alex ', ' Eric ', ' Rain '] 22, write code, like the following table, as required to achieve each function
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 deleted element's value and the list after the element is deleted G. Delete the 3rd element in the list and output the list after the delete element
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 key B. 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, "K1" corresponds to "Alex", Output the modified dictionary F. Append an element 44 to the K3 corresponding value, and 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 a utf-8 encoded byte and output, then convert the byte to a 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 (i)

Related Article

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.