NEW
Font size
Worksheetsvariables , if … else, while and loop for_HKICO_Python
Total questions: 27
Worksheet time: 14mins
What is the output of the following code?
A. JamesJamesJamesJamesJamesJames
B. JamesJamesJamesJamesJames
C. JamesJamesJamesJames
D. JamesJamesJames
E. Error: invalid syntax
A. 20
B. 21
C. 10
D. 30
E. None of the above
E. It doesn’t generate any output.
What gets printed?
A. 4
B. 3
C. 2
D. 1
E. 7
A. 2, 4, 6
B. 0, 1, 2, 4, 5, 6
C. 0, 1, 4, 5
D. 0, 1, 4, 5, 6, 7, 8, 9
E. 1, 2, 4, 5, 6
Consider the following code,
What is the output?
A. 1
B. 2
C. 3
D. 4
E. 5
What gets printed as the output of the below code?
A. 1
B. 2
C. 3
D. 4
E. None of the above
Consider the following code,
What is the output?
A. 7
B. 6
C. 4
D. 2
E. 1
A. The recursive function never terminates
B. -1
C. 5
D. 0
E. None of the above
What is the expected output of the program?
A. None
B. a
C. C
D. 2
E. None of the above
Which one will display when this code is run?
E. None of the above
What is the Output of the following code?
A. [0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5]
B. [0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5]
C. [0.5, 1, 1.5, 2]
D. [0.5, 1, 5.5]
E. The Program executed with errors
Please select the correct expression to reassign a global variable “x” to 20 inside a function fun1()
A. global x =20
B. global var x
x = 20
C. global.x = 20
D. global x
x = 20
E. None of the above
What is the output of the following variable assignment?
A. Error
B. 76
C. 1
D.75
E. None
What is the output of the following nested loop?
Given the nested if-else structure below, what will be the value of x after code execution completes
A. 2
B. 0
C. 3
D. 4
E. 1
Which is the better statement if x+=1 is removed?
A. There is no difference
B. The loop is infinite
C. The print function is stopped
D. The output equals to 10
E. None of the above
What is the expected output of the following code?
A. 4
B. 5
C. 6
D. 7
E. None of the above
What is the output?
A. 154 6 25
B. 155 6 24
C. 154 5 24
D. 155 5 25
E. None of the above
A. [A , F]
B. [‘A’ , ‘F’]
C. [B , E]
D. [‘B’ , ‘E’]
E. None of the above
Given the code:
Which of the following is code correct if the output is I ?
A. print(x[3])
B. print(x[4])
C. print(var[2])
D. print(var[3])
E. None of the above
Given the code:
Which of the following statement is/are correct?
A. split() is to split a string into a list
B. [word] = line
C. The output is ordered by ascending order
D. All the above are correct
E. None of the above
Which of the following is not a Python built-in types?
A. int
B. double
C. complex
D. list
E. All of the above
A. 61
B. 42
C. 13
D. 11
E. None of the above
A. 0
B. 10
C. 170
D. 495
E. None of the above
A. 0
B. 10
C. 170
D. 495
E. None of the above
A. True
B. False, list a is consumed but b is not, because list a is not explicit
C. False, every instance of list does not equal (evaluate to True) in case of ‘==’ operator
D. False, values of elements are not equal in list a and b, they appear to be the same when printed out
E. None of the above
