A summary of Python flight module evaluation

Source: Internet
Author: User

1. Explain the meaning of "=", "= =", "+ =" respectively (oral)

= For an assignment statement, one variable value to another value = = To determine the condition, to determine whether two values are equal to + = is the assignment a+=1 means a=a+1

2. What is the relationship of two variable values? Oral
N1 = 123456
N2 = N1

Give 123456 to N1, and then give N1 to N2, meaning N1 n2 points to 123456 this address

3. Please write down the number of digits (oral) of utf-8 and GBK encoded by "Road flying Learning City" respectively.

A Chinese with Utf-8 represents 3 bytes gbk accounted for 2 bytes so Luffy learning City with Utf-8 represents 12 bytes gbk accounted for 8 bytes where 12 bytes equals 96 bits 8 bytes 64 bits

4. Brief description of several data types in Python (dictate)

The data type is divided into: basic type, data set. Basic types include: numeric type (shaping, long integer, float, plural), String type, Boolean type. The dataset types are: List, Ganso, Dictionary, collection.
In general, data types are divided into numbers, strings, lists, dictionaries, meta-ancestors, Booleans, collections

5. What are the variable and immutable data types? Oral

mutable: String, List, collection, dictionary value immutable: number, String, Boolean, Ganso, dictionary key

6. The Yuan Zu, list, dictionary there is no length limit? (oral)

No, as defined by memory size.

7. Explain ' and ', ' or ', ' not ' (dictate)

and C speech is the same as or not, and,or,not both the logical operator and both are true, or trueor indicates that both have a Boolean true if the result is true and the reverse is falsenot to the inverse, as x is True,not X is False

  

8. Differences between tuples and lists (dictate)

Tuples are also called read-only lists, immutable, and unordered. The list is ordered and can be modified.

9. Enumerate a bunch of cases where the Boolean value is False (dictate)

Empty list [], empty Dictionary {}, Empty Ganso (), empty string "" 0

The difference between 10.python2 and Python3 for long (longer shaping).

There are python2 int and Long,int 32-bit systems with a maximum of 32 bits and a long beyond 32 bits. The 64-bit system is 64-bit. All of the python3 are int. Long does not refer to the positioning width in python.

11. Variable naming specification? Oral

The first letter cannot be a number, and the variable name can only contain English, numerals, and underscores _
1. Variable names can only be any combination of letters, numbers, or underscores.
2. The first character of a variable name cannot be a number.
3. The keyword cannot be declared as a variable name.
The variable name should not be too long, it is best not to use Chinese and pinyin, there can not be confused variable names, such as the name does not mean.

12. Explain the differences between Unicode and utf-8 (or the role of Unicode in Python3) (dictate)

Unicode, also known as the Universal Code, covers the world's code, all characters and symbols are represented by a minimum of 16 bits (2 bytes), and other encodings have a corresponding mapping relationship. Utf-8 is optimized for Unicode, uft-8 only occupies 1 bytes for English, 2 bytes for European characters, 3 bytes for East Asian characters, and 4 bytes for special characters. In Python3, the default in memory storage code is Unicode, in order to make it easier for people in different countries to view the code.

13. Depth copy-Reference and copy (), deepcopy () difference (dictate)

1. When assigning a value, point to the same list address, if the A list is re-assigned to another list, B still points to the previous address, B list does not change, if the value of a column table changes, then B will follow the change. 2. When using copy (), the equivalent of the entire list including the contents of the complete copy to you, not to the same address, a value change, b list does not follow the change. However, if the a list is nested, the values in the nested list change, and the nested list in copy list B changes, because the list in the table is pointing to the same address, which is equivalent to 1.3. If you use Deepcopy (), the number of addresses in the table will be different. So change the number of nested lists in List A and B will not change.

Default character encoding for 14.python2 and Python3 (dictate)

Python2 default character encoding is ASCIIpython3 default encoding is Unicode

15. Features of the collection (dictate)

Deterministic: elements must be hash-capable. Cross-specific: elements are not identical. Disordered nature.

16. List [' Alex ', ' Egon ', ' Yuan ', ' wusir ', ' 666 '] (programming)

1. Replace 666 with 999
2. Get the "Yuan" index
3. Assuming that there are several elements ahead, the Shard gets the last three elements

16. List [' Alex ', ' Egon ', ' Yuan ', ' wusir ', ' 666 '] (programming) 1. Replace 666 with 999 2. Gets the "Yuan" index 3. Assuming that there are several elements ahead, the Shard gets the last three elements Li =[' Alex ', ' Egon ', ' Yuan ', ' wusir ', ' 666 ']li[-1] = ' 999 ' Print (LI) print (Li.index (' Yuan ')) Last3 = Li[-3:]print (LAST3)

  

17. Increase and deletion of dictionaries (programming)
{"Development": "Development Brother", "Op": "Ops brother", "Operate": "Operation Fairy", "UI": "UI Fairy"}

DIC = {"Development": "Development Little Brother", "Op": "Ops little Brother", "Operate": "Operation Fairy", "UI": "UI Fairy"} #增dic [' Manage ']= ' Alex ' Print (DIC) #删del dic[ ' Development ']print (DIC) #改dic [' manage '] = ' oldboys ' Print (dic) #查看find = Dic.get ("UI") print (Find)

  

18. Calculating 1+2+3...+98+99+100 (programming questions)

#18. Calculating 1+2+3...+98+99+100 (programming questions) # count = # counts =0# while count<=100:#     counts=count+counts#     print (counts) #     Count +=1count =0for i in Range (1,101):    count = Count+iprint (count)

  

19. Create Fun template programs (programming questions)
Requirements: Waiting for the user to enter a name, place, hobby, according to the user's name and hobbies to carry out arbitrary reality
Such as: Beloved lovely xxx, favorite in XXX place dry xxx

# 19. Create Fun template Program (programming problem) # Requirements: Wait for the user to enter a name, place, hobby, according to the user's name and hobby of arbitrary reality # such as: Beloved lovely xxx, favorite in XXX place dry xxx# username = input ("Please enter name >>") use Rpalce = input ("Please enter location >>") Userhobby = input ("Please enter Hobby >>") print ("Beloved lovely%s, most like the%s local dry%s"% (Username,userpalce, Userhobby))

  

20. Write a three-time authentication (programming)
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

# 20. Write a three-time authentication (programming) # 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 allowed to repeat the input three times # _username1 = ' Seven ' _username2 = ' Alex ' _password = ' 123 ' Count =0while count<3:    username = input ("name >>")    password = input ("Password >>"    if (username==_username1 or username==_username2) and password ==_password:        print ("Login succeeded") Break    else:        print ("Login failed")    count+=1

  

21. Cut the string "luffycity" to "Luffy", "City" (programming)

# 21. Cut the string "luffycity" to "Luffy", "City" (programming) info = "Luffycity" Print (Info[0:5]) print (info[5:])

  

22. Guess Age Games (programming questions)

# 22. Guess Age =20count = 0while count<3:    user_age = input ("Please enter Age >>")    if User_age.isdigit () is True :        if age = = Int (user_age):            print ("Congratulations") break        elif Int (user_age) >age:            print ("Guess Big, try again")        else:            print ("Guess small, try again")    else:        print ("Please enter a number")        pass    count+=1

  

23. Find all the even numbers between the 1~100 (also odd and, using while loop write) (programming questions).

# 23.1~100 all even-numbered and (also odd and, using while loop write) (programming questions). Count =0sumn=0while count<=100:    if count%2==0:        sumn =count+sumn    count+=1print (sumn)

  

24. Receive 100 points from the keyboard (0~100), the required output of its corresponding grade a~e. Among them, 90 points above is ' A ', 80~89 is divided into ' B ', 70~79 is divided into ' C ', 60~69 is divided into ' D ', and 60 points below is ' E '. (Programming Questions)

# 24. Receive 100 points from the keyboard (0~100), which requires the output of its corresponding grade a~e. # of these, 90 points above is ' A ', 80~89 is divided into ' B ', # 70~79 into ' C ', 60~69 divided into ' D ', # 60 points below for ' E '. (programming question) Usergrade = input ("Please enter score >>") if Usergrade.isdigit () is True:    if int (usergrade) >=90:        print ("A")    elif Int (usergrade) >=80:        print ("B")    elif Int (usergrade) >=70:        print ("C")    elif Int ( Usergrade) >=60: Print ("        D")    else:        print ("E") Else:    print ("Please enter Number")    Pass

  

25. Enter a year to determine whether the year is a leap years and output the results. (The program can be reused using while True) (programming questions)
Note: A year in which one of the following two conditions is met is a leap years. (1) can be divisible by 4 but not divisible by 100. (2) can be divisible by 400.

# 25. Enter a year to determine if the year is a leap years and output the results. (The program can be reused using while True) # Note: A year in which one of the following two conditions is met is a leap years. (1) can be divisible by 4 but not divisible by 100. (2) can be divisible by 400. # while True:    year_input = input ("Please enter year >>")    if Year_input.isdigit () is true:        if (int (year_input)%4 = = 0 and Int (year_input)%100!=0) or int (year_input)%400==0:            print ("Leap year")        else:            print ("Common year")    elif Year_ input = = ' Q ': Break    Else:        Pass

  

26. The following string: N = "lu Fei Learning City" (programming question)

-Converts a string to a utf-8 character encoding, and then converts the converted bytes to the Utf-8 character encoding
-Converts a string to a GBK character encoding, and then converts the converted bytes to the Utf-8 character encoding

# 26. There is the following string: N = "Luke City" (programming question) # #-Converts a string into a utf-8 character encoding, converts the converted bytes to a utf-8 character encoding #-converts a string into a GBK character encoding, and converts the converted bytes to a utf-8 character encoding # n = "Luke City" n8 = N.encode (encoding= ' Utf-8 ') print ("Transcode to utf8>>%s"%n8) N9 = N8.decode (encoding= ' Utf-8 ') print (" Decoded to utf8>>%s "%n9) NGBK = N.encode (encoding= ' GBK ') print (NGBK) NDGBK = Ngbk.decode (encoding= ' GBK ') print (NDGBK)

  

27. Connect each element in the list [' Alex ', ' Steven ', ' Egon '] to a string (programming) using ' \_ '

# 27. Connect each element of the list [' Alex ', ' Steven ', ' Egon '] to a string (programming) # Li =[' Alex ', ' Steven ', ' Egon ']# a = ("\_") using ' \_ '. Join (LI) # prin T (a) s = ' \_ ' Print (S.join (LI))

  

28. Customize two, and seek the intersection, the collection, the difference set. Programming

A1 ={3,4,5,6}a2 ={1,2,3,4}jiao =a1|a2print (jiao) cha = a1-a2print (cha) bing = a1&a2print (Bing)

  

29. Find all numbers within 100 that cannot be divisible by 3, and place these numbers in the list sum3=[] and find the sum and average of these numbers. (when calculating, tell the learner that sum is a keyword and cannot be used as a variable) (programmed)

# 29. Find all numbers within 100 that cannot be divisible by 3, and place them in the list sum3=[], # and find the sum and average of these numbers. (when calculating, tell the learner that sum is a keyword and cannot be used as a variable) (programming) sum3 =[]count =0sums =0while count<=100:    if count%3!=0:        sum3.append ( Count)        sums =sums+count    count+=1print (sums) print (SUM3) print (Sums/len (SUM3))

  

30. Print the following form according to the contents of the Dictionary (programming)
You can not print the effect of neat alignment, mainly for students to get key and value.
{"Development": "Development Brother", "Op": "Ops brother", "Operate": "Operation Fairy", "UI": "UI Fairy"}
The effect is as follows:
1. Removed the UI
2. Modified the operate

```
Development---development small brother
OP---ops little brother.
Operate---little Fairy
```

# 30. The following form (programming) can be printed according to the contents of the dictionary to not print the effect of neat alignment, mainly for the learner to get key and value. # {"Development": "Development Little Brother", "Op": "Ops little Brother", "Operate": "Operation Fairy", "UI": "UI Fairy"}# effect as follows: # 1. ui# 2 was removed. Modified operate## ' # Development---Development small Brother # OP---ops little Brother # Operate---Little fairy # "info ={" Development ":" Development Little Brother "," Op ":" Yun-brother "," Operate " : "Operation Fairy", "UI": "UI Fairy"}del info[' UI ']print (info) info["Operate"]= ' Little Fairy ' print (info) # for items in Info.items (): #     Print (items) for I in info:    print (i+ '----------' +info[i])

  

31. Assuming that the one-year periodic interest rate is 3.25%, to calculate the need for an excessive number of young, 10,000 yuan of one-year time deposit to double the band? (Programming Questions)

# 31. Assuming that the one-year periodic interest rate is 3.25%, calculate the need for too many young, 10,000 yuan of one-year term deposits to double the band? (programming question) money = 10000money = 10000interest = Moneycount = 0while True:    count + = 1    interest = interest * (1 + 3.25/1 XX)    if interest//money = = 2:        print (count)        Breakmoney =10000rate = 0.0324years =0while money<20000:    Years+=1 Money    =money* (1+rate) print (years)

  

32. The list is added to the search (can be indexed, whether the value exists in the list). Programming

[' Alex ', ' Egon ', ' Wusir ', ' Wen ', ' Jing ']

# 32. The list is added to the search (can be indexed, the value exists in the list). (programming) # # [' Alex ', ' Egon ', ' Wusir ', ' Wen ', ' Jing ']li =[' Alex ', ' Egon ', ' Wusir ', ' Wen ', ' Jing '] #增li. Append (' Wang ') print (LI) # Delete Li.remove (' Wang ') print (LI) del li[-1]print (LI) #改li [1] = ' eeee ' Print (LI) #查print (Li.index (' Alex '))

  

33. Guess the game. Preset an integer between 0~9, let the user guess and enter the number of guesses, if the number is greater than the preset, the display is "too big", less than the preset number, the display "too small", so loop, until the number of guesses, show "Congratulations!" You guessed it! (Programming Questions)

# 33. Guess the game. Preset an integer between 0~9, let the user guess and enter the number of guesses, # if it is greater than the preset number, the display is "too big", less than the preset number, the "Too small", # so loop, until the number guessed, show "Congratulations!" You guessed it! (programming question) The_number = 9while 1:    user_guess = input ("Guess age")    if User_guess.isdigit () is True:        if The_number ==in T (user_guess):            print ("Congratulations")            break        elif Int (user_guess) >the_number:            print ("Too big")        else:            Print ("Too small")

  

34. Write a Python program, enter two numbers, compare their sizes, and output the larger of them. (Programming Questions)

# 34. Write a Python program, enter two numbers, compare their sizes, and output the larger of them. (programming question) Number1 = input ("Enter a number") Number2 = input ("Enter a number") if Number1.isdigit () is True and Number2.isdigit () is true:< C0/>if number1>number2:        print (NUMBER1)    else:        print (number2) Else:    print ("Input error, please re-enter")    Pass

  

35. There are four numbers: 1, 2, 3, 4, how many different and non-repeating numbers of three digits can be formed? What's the number? (Programming Questions)
Program Analysis: Can be filled in hundreds, 10 digits, single digit numbers are 1, 2, 3, 4. Make all the permutations and then remove the permutations that do not meet the criteria.

# 35. There are four numbers: 1, 2, 3, 4, how many different and no duplicates of the three-digit number? What's the number? (programming Problem) # program analysis: Can be filled in the hundred, 10 digits, digit digits are 1, 2, 3, 4. #             make up all the permutations and then remove the permutations that don't meet the criteria. Nums =[]for index1 in range (1,5): for    index2 in range (1,5): for        index3 in range (1,5):            if Index1!=index2 and in Dex2! = index3 and Index3! = index1:                num = 100*index1 +10*index2 +index3                if num not in Nums:                    nums.append (num) p Rint (nums) print (len (nums))

  

36. A company uses a public telephone to transmit data, the data is a four-bit integer, in the transmission process is encrypted, the encryption rules are as follows: Each digit is added 5, and then divided by the remainder of 10 instead of the number, and then the first and fourth exchange, the second and third exchange. (Programming Questions)

# 36. A company uses a public telephone to pass data, the data is a four-bit integer, is encrypted during delivery, # Encryption rules are as follows: Each digit is added 5, and then divided by the remainder of the 10 instead of the number, # and then the first and fourth bits swap, the second and third exchange. data = input ("Input 4 digits >>") Data =list (". Join (data)) print (data) for Index,i in Enumerate (data):    print ( Data[index])    data[index] = (int (i) +5)%10print (data) Data.reverse () print (data)

  

37. Ask for the prime number within 100 and. (Programming Questions)

# 37. Ask for the prime number within 100 and. (programming Problem) # Prime: Prime is also called Prime, prime number is defined as the number of natural numbers greater than 1, except 1 and itself no longer have other factors called prime. # idea: 1. The number of 1~100 is traversed first to get this number is not a prime # 2. Divided by this small integer (except 1 and itself), to obtain the remainder, judging by the remainder whether it is a prime number for I in range (1,100):    a =1 for    J I n Range (int (I/2)):        if (1+i)% (2+j) ==0:            a =0            break    If a ==1:        print (i+1)

  

38. Binary, Decimal, hexadecimal conversion (calculation problem, let learners use the calculator, do not use the built-in method of programming)
Decimal Turn binary: Bin ()
Decimal to 16 binary: Hex ()
Decimal to octal: Oct ()
Binary Turn 10 binary: 1010: equivalent to 8+2=10
hexadecimal to binary: such as 0x9a: equivalent to 10011010 and then 10 binary is the corresponding
1 1 1 1 1 1 1 1
128 64 32 16 8 4 2 1 10011010=128+16+8+2=154




39. The bonus awarded by the Enterprise is based on the profit percentage. If the profit (I) is less than or equal to $100,000, the bonus may be raised by 10%;
Profit above 100,000 yuan, less than 200,000 yuan, less than 100,000 yuan in part by 10% commission, higher than 100,000 yuan portion, can commission 7.5%;
Between 200,000 and 400,000, higher than 200,000 yuan portion, can commission 5%, 400,000 to 600,000 is higher than 400,000 yuan portion, can commission 3%;
Between 600,000 and 1 million, higher than 600,000 yuan of the portion, can commission 1.5%, higher than 1 million yuan, the portion of more than 1 million yuan by 1% Commission,
Enter the current month profit I from the keyboard, the total bonus should be issued? Programming

While true:     money = input (' profit: ')     if money.isdigit () = = True:          If int. <= 100000:               Print ("Bonus:%s" (int (money) *10/100))          elif Int (money) <= 200000:               print ("Bonus:%s"% (((int (money)-100000) *7.5/100) +100000* 10/100))          elif Int (money) <= 400000:               print ("Bonus:%s"% ((((Int (money)-200000) * 5/100))          elif Int (cash) & lt;= 600000:               print ("Bonus:%s"% ((((Int (money)-400000) * 3/100))          elif Int (money) <= 1000000:               print ("Bonus for :%s "% ((((Int (money)-600000) * 1.5/100))          else:               print (" Bonus:%s "% ((((Int (money)-600000) * 1/100))          BR Eak     Else: Money          = input (' input error, please re-enter: ')

  

A summary of Python flight module evaluation

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.