Question 1: What is the output of the following piece of code?
1.1. What is the output of the following piece of code ? a. 1 3 6 8
b. 2 4 7
A
c. 1 3 6
d. None of above
1.2. What will be value of n after execution of this code ? a. 17
b. 23
c. 18
d. None of above
1.3. a. 3
b. 0 1 2 3
c. 1 2 3 4
d. None of above
1.4. a. 5
b. 23
c. Error
d. 24
1.5 For the following piece of code, what will be printed a. 1
in python shell if x equal to 1:
b. 2
c. 3
d. None of above
1.6 a.0 1 2
b. 0
c. 3
1
What will be printed out if the user inputed s equals d. None of above
to 0
a. 0 1 2
1.7 b. 0
c. 3
What will be printed out if the user inputed s equals d. None of above
to 3
1.8 a. 5
b. 3
c. 0
d. None of above
1.9 a. 75
b. 25
c. 17
d. None of Above
1.10 a. 1000
b. 10000
c. 100000
d. Error
1.11 What is the output of execution the following code ? a. b
c
['a', 'b', 'o', 'c', 'p']
b. b
2
['a', 'b', 'p', 'c', 'p']
['a', 'b', 'c', 'p']
c. a
b
o
d. None of Above
1.12 Which of the following statements create an a. num1 = list(range(0,100))
inclusive list of integers from 0 to 100.
b. num1 = list(range(0,101))
c. num1=list(range(1,100))
d. None of above
1.13 a. Income is greater than 3000
What is the output of of the following piece of code
? b. Income is greater than 4000
c. Income is greater than 3000
and less than 4000
d. None of Above
What is the output of the following piece of code ?
1.14 a. 6
b. 19
c. 23
d. Nothing Above
What will be output of the following piece of code?
1.15 a. 1 3 5 7 9
b. 1 2 3 4 5
3
c. 2 4 6 8 10
d. 0 2 4 6 8 10
1.16 What is the output of the following piece of code?
a. [ 12 13 14 15 16 20]
b. [12 11 13 14 15 16 20]
c. [12 11 14 15 16 20]
d. [12 11 13 14 15 16 20 7]
1.17
What is the output of the folllowing piece of code? a. 2
b. 0
c. Error
d. None of above
What is the output of the following code ?
1.18 a. TRUE
a=5
b. FALSE
b = 10
c. ERROR
c = 15
d. NONE OF ABOVE
output = (a<b) and (b < c )
print(output)
1.19 What is the output of the following piece of code ? a. 25
b. x0
4
c. 35
d. None of above
1.20 a. Abc
Which of the following is not a valid
variable name? b. abc123
c. 123abc
d. abc_123
5
Question 2
2.1. Write a piece of code to ask the user for two numbers, reads them, then print out the sum of
the two numbers.
2.2. Write a while loop fragment that calculates the following:
6
2.3. A certain professor gives 100-point exams that are graded on the scale as follows:
90-100:A
80-89 : B
70-79 : C
60-69 : D
Less than 60 : F
Write a program that accepts an exam score as input and prints out the corresponding grade
7
Question 3 -
What is the output of the following piece of code ?
21