1、
for was in ___ : print (was)
Which option do not meet the requirements of the above syntax of the space program?
A、"Hello"
B、(1,2,3)
C、range(0,10)
D、{1;2;3;4;5}
Analytical: for .. .. in the latter needs to be in an iterative type (combination type), {1; 2; 3; 4; 5} is not a valid data type Python.
2、
for i in range(0,2): print(i)
Which option is the output of the above program?
A、0 1 2
B、0 1
C、1 2
D、1
Analytical:
Range ( 0, 2) outputs two values: 0 and 1.
3、
k=10000 while k>1: print(k) k=k/2
Which option gives the number of times the output of the program?
A、14
B、15
C、1000
D、13
Resolution:
Please follow the program calculates or run the program in IDLE get results.
4. Which option is the three basic structure of the program?
A, sequential structure, the jump structure, a cyclic structure
B, process structure, object structure, function structure
C, sequential structure, cyclic structure, a branched structure
D, process structure, cyclic structure, a branched structure
Analysis:
No object structure, the jump structure, process, structure and other statements.
5. Which of the description of the structure of the loop is wrong?
A, an infinite loop can not quit, no effect
B, and the loop through the loop conditions are the basic structure of the cyclic structure
A method of operating mode C, according to the program loop is repeatedly executed rearwardly condition determination result of
D, is the cycle of the basic control structure of a program
Analysis: infinite loop can be used to test the performance, the form of an endless loop can break to exit, for example: X = 10 the while True: X = X -. 1 IF X ==. 1 : break infinite loop has its effect.
6, on the Python statements P = -P, describe which option is correct?
A, P is equal to its negative
The absolute value of B, P is
C、P=0
D, P assigned to its negative
Analytical:
the Python the assignment symbol, == equality is equal to the symbol is determined.
7. Which option is used to determine the current branch structure in Python statements?
A, indents
B, braces
C, quotes
D, colon
Analysis:
Indent expression hierarchy.
8. Which of the following is the result of the implementation of the code?
for s in "PYTHON": if s=="T": continue print(s,end="")
A、PYHON
B, PY
C、PYTHON
D、TT
Resolved:
the Continue ended when cycles, but not out of the current cycle.
9, which option is the random library functions for generating random decimal?
A、getrandbits()
B、random()
100, Rand ()
D, randrange ()
Analytical:
the randint (), getrandbits (), randrange () are generated random integer, random () generates a random decimal between 0 and 1.
10, on try-except, describe which option is wrong?
A, expression of one kind of a branched structure characteristic
B, the use of exception processing, the program will no longer error
C, NameError is an unusual type
D, an abnormality procedures for capture and processing
Resolution:
Use exception handling, the program may run without error, but that can go wrong on logic. Bug is a big concept, refers not only to run the code error, but also represent the functional logic errors.