python test questions

First, fill in the blank 
1. Python indicated using symbolic notation; to divide the block. 
2, Python sequence type comprises three kinds ,,; 
  is the only type of mapping Python. 
3, the variable data type in Python are immutable data class 
type has. 
4, Python numeric types are divided into subtypes ,, the like. 
5, set s = 'abcdefg', then the s [3] value, s [3: 5] value, 
S [: 5] value, s [3:] value, s [:: 2] value is , S 
[:: -. 1] value, s [-2: -5] value Yes. 

. 6, L = Range (100) 
. 1) taking a first to third element _______ 
2) taking the inverse of the second element _______ 
3) after ten elements taken _______ 
4) with the L replicated to L1 _______ 

7 determining dict there is a method of using key _______ 

8, obtain the number of elements in the list, and to a method of appending an element are ______ _______ 

What is the output 9. the following code would be: _______ 
DEF extendList ( Val, List = []): 
list.append (Val) 
return List 
List1 = extendList (10) 
List2 = extendList (123, [])
= extendList list3 ( 'A') 
Print ( "% S = List1" List1%) 
Print ( "% S = List2" List2%) 
Print ( "% S list3 ="% list3) 


10. The procedure is the following output: _________ 
X = True 
Y = False 
Z = False 
IF X and Y or X: 
Print "Yes" 
the else: 
Print "NO" 

2, choose 
one. Which of the following statements are illegal in Python? () 
A, X = Y = Z = B. 1, X = (Y + Z =. 1) 
C, X, Y = Y, X D, X + Y = 
2. About Python memory management, the following statement is wrong is () 
A, variables without prior declaration B, variable without first creating and assigning direct use of 
C, variables do not need to specify the type D, you can use del release resources 
3. Which of the following is not a Python legal identifier () 
a, B Int32, 40XL C, D Self, __ name__ 
. 4, the following statement is false () 
a, in addition to a dictionary, objects may be used in all standard testing Boolean 
Boolean B, an empty string value is False 
Boolean C, an empty list of objects False value 
D, any digital object Boolean value 0 is False
5, the following expression is True is () 
A, + 5. 4J> 2-3j B,. 3> 2> 2	 
C, (3,2-) <( 'A', 'B') D, 'ABC '>' XYZ ' 
. 6, the Python unsupported data types () 
a, B char, C int, a float D, List 
. 7, on the string following argument is false () 
a, it should be regarded as the character length 1 string		 
B, string \ string end flag 0 
C, either in single quotes, or double quotes may be used to create a string 
D, three quoted string can contain special characters like carriage return linefeed 
8, not less creating a dictionary statement is () 
a, B dict1 = {}, = {dict2. 3:}. 5	   
C, dict3 = {[l, 2,3]: "UESTC"}	  
D, dict4 = {(1,2, . 3): "UESTC"} 
. 9, the following Python statement is correct () 
a, min = X IF X <Y the else Y B, max = X> Y X:? Y 
C, IF (X> Y) Print X D , the while True: Pass 
10, Python unsupported data types 
a, char 
. 11. 
B, int
C, a float 
D, List 

X = "foo" 
Y = 2 
Print (X + Y) 
A.foo B.foofoo C.foo2 D.2 E.An thrown Exception IS 

12 is, on the string following argument error is 
A, characters should be treated as a string of length 1 
B, string \ 0 mark the end of the string 
	C, either with single quotes, you can also create a string enclosed in double quotes 
	D, three-quoted string may contain line breaks back special characters such as car 
13, the following statement can not create a dictionary is 
	a, DIC1} = { 
	B, DIC2 = {123: 345} 
	C, dic3 = {[l, 2,3]: 'UESTC'} 
	D, dic3 = {(l, 2,3): 'UESTC'} 
14. = {Kvps '. 1':. 1, '2': 2} 
theCopy = kvps 
kvps [ '. 1']. 5 = 
SUM = kvps [ '. 1'] + theCopy [ '. 1'] 
the Print SUM 
A.1 B.2 C D.10 .7 
15, what would be an illegal Boolean expression: 
  	A. x in range (6) B.3 = a
   CE> ==. 4. 5 and F D (X-. 6)>. 5  
16, known x = 43, ch = 'a ', y = 1 , the expression (x> = y and ch < 'b' and y) values are
	A, B 0,. 1 C, error D, True 
. 17, the following expression is True is returned: 
	A,. 3> 2> 2 
	B, ' ABC '>' XYZ ' 
	C, 0x56> 56 is 
	D, (3,2-)> (' a ',' B ') 
18 is, Python statements following the right thing (multiple choice) 
	a, X = min IF X <Y the else Y 
	B, max = X> Y X:? Y 
	C, IF (X> Y) Print (X) 
	D, the while True: Pass 
. 19, the following statements is correct: 
	the role of a, continue statement is the end of the whole cycle is executed 
	B, the loop body can break statement in 
	C, using the same continue statement or break statement in the circulation in vivo effects of 
	D, exit from the multilayer loop nesting, only the goto statement 

20.x = "foo" 
   Y = 2 
   Print (X + Y) 
A.foo B.foofoo C.foo2 D.2 E.An IS thrown Exception 


three programming problems. 
1, d = { 'a' : 1, 'b': 2, 'c': 3} print out the key, value pair
2, please write some Python code that implements delete a list inside of repeating elements. 
3, Python how to define a function, and try to write a function that, given n, n return to 
Fibonacci in the Fibonacci sequence.
. 4, dicta = { "A":. 1, "B": 2, "C":. 3, "D":. 4, "F": "Hello"} 
 dictb = { "B":. 3, "D": 5, "e": 7, "m": 9, "k": "world"} 
 asked to write code to implement the sum of two dictionaries, the key corresponding to different values of retention, the same key value corresponding to the phase after the addition of a reservation if the string is spliced to, as an example of results obtained: 
 dictc = { "A":. 1, "B":. 5, "C":. 3, "D":. 9, "E":. 7, "m":. 9, "F": "Hello", "K": "World"} 

. 5, to print out all of the "Narcissus number", called "Narcissus number" refers to a three-digit number, digits of which cube and is equal to the number itself. For example: 153 is a "Narcissus number", because cubic cubic cubic +3 +5 1 = 153. 

6, 1,2,3,4 figures, the number of other with no repeat of the three-digit numbers can be composed? How much are?

  

Guess you like

Origin www.cnblogs.com/yanzifamily/p/10953467.html