QUIZ ON : PROGRAMMING AND PROBLEM SOLVING THROUGH PYTHON - OPERATORS EXPRESSIONS AND PYTHON STATEMENTS

OPERATORS EXPRESSIONS AND PYTHON STATEMENTS

00:00:00

What will be the output of the following Python code?

  x = "abcdef"  i = "a"  while i in x:      print(i, end = " ")

Option A. no output
Option B. i i i i i i …
Option C. a a a a a a …
Option D. a b c d e f
True Answer C

Explanation :
As the value of i or x isn’t changing, the condition will always evaluate to True.

What will be the output of the following Python code?

  x = "abcdef"  i = "a"  while i in x:      print(i, end = " ")

Question No# : 01 out of 20



What is the answer to this expression, 22 % 3 is?

Option A. 7
Option B. 1
Option C. 0
Option D. 5
True Answer B

Explanation :
Modulus operator gives the remainder. So, 22%3 gives the remainder, that is, 1.

What is the answer to this expression, 22 % 3 is?

Question No# : 02 out of 20



Which one of the following has the highest precedence in the expression?

Option A. Exponential
Option B. Addition
Option C. Multiplication
Option D. Parentheses
True Answer D

Explanation :
Just remember: PEMDAS, that is, Parenthesis, Exponentiation, Division, Multiplication, Addition, Subtraction. Note that the precedence order of Division and Multiplication is the same. Likewise, the order of Addition and Subtraction is also the same.

Which one of the following has the highest precedence in the expression?

Question No# : 03 out of 20



What will be the output of the following Python code?

    d = {0: 'a', 1: 'b', 2: 'c'}    for x in d.keys():        print(d[x])

Option A. 0 1 2
Option B. a b c
Option C. 0 a 1 b 2 c
Option D. none of the mentioned
True Answer B

Explanation :
Loops over the keys and prints the values.

What will be the output of the following Python code?

    d = {0: 'a', 1: 'b', 2: 'c'}    for x in d.keys():        print(d[x])

Question No# : 04 out of 20



What will be the output of the following Python code?

  i = 0  while i < 5:      print(i)      i += 1      if i == 3:          break  else:      print(0)

Option A. 0 1 2 0
Option B. 0 1 2
Option C. error
Option D. none of the mentioned
True Answer B

Explanation :
The else part is not executed if control breaks out of the loop.

What will be the output of the following Python code?

  i = 0  while i < 5:      print(i)      i += 1      if i == 3:          break  else:      print(0)

Question No# : 05 out of 20



Which of the following is not Logical operator?

Option A. and
Option B. or
Option C. not
Option D. Assignment
True Answer D

Explanation :

Which of the following is not Logical operator?

Question No# : 06 out of 20



What will be the output of the following Python code?

for i in range(int(2.0)):      print(i)

Option A. 0.0 1.0
Option B. 0 1
Option C. error
Option D. none of the mentioned
True Answer B

Explanation :
range(int(2.0)) is the same as range(2).

What will be the output of the following Python code?

for i in range(int(2.0)):      print(i)

Question No# : 07 out of 20



What will be the output of the following Python code snippet?

Option A. 0 1 2 3 4 …
Option B. 0 1
Option C. 3 4
Option D. 0 1 2 3
True Answer C

Explanation :
Variable x is incremented and printed twice.

What will be the output of the following Python code snippet?

Question No# : 08 out of 20



What will be the output of the following Python code?

i = 5

while True:      if i%0O9 == 0:          break      print(i) 

 

Option A. 5 6 7 8
Option B. 5 6 7 8 9
Option C. 5 6 7 8 9 10 11 12 13 14 15 ….
Option D. error
True Answer D

Explanation :
9 isn’t allowed in an octal number.

What will be the output of the following Python code?

i = 5

while True:      if i%0O9 == 0:          break      print(i) 

 

Question No# : 09 out of 20



Which is the most comfortable loop?

Option A. do..while
Option B. while
Option C. for
Option D. if..elif
True Answer C

Explanation :

Which is the most comfortable loop?

Question No# : 10 out of 20

What will be the output of the “hello” +1+2+3?

Option A. hello123
Option B. hello
Option C. Error
Option D. hello6
True Answer C

Explanation :
Cannot concatenate str and int objects.

What will be the output of the “hello” +1+2+3?

Question No# : 11 out of 20



What will be the output of the following Python code?

for i in range(0):      print(i)

Option A. 0
Option B. no output
Option C. error
Option D. none of the mentioned
True Answer B

Explanation :
range(0) is empty.

What will be the output of the following Python code?

for i in range(0):      print(i)

Question No# : 12 out of 20



What will be the output of the following Python code?

  i = 5  while True:      if i%0O11 == 0:          break      print(i)      i += 1

Option A. 5 6 7 8 9 10
Option B. 5 6 7 8
Option C. 5 6
Option D. error
True Answer B

Explanation :
0O11 is an octal number.

What will be the output of the following Python code?

  i = 5  while True:      if i%0O11 == 0:          break      print(i)      i += 1

Question No# : 13 out of 20



What is the output of this expression, 3*1**3?

Option A. 27
Option B. 9
Option C. 3
Option D. 1
True Answer C

Explanation :
First this expression will solve 1**3 because exponential has higher precedence than multiplication, so 1**3 = 1 and 3*1 = 3. Final answer is 3.

What is the output of this expression, 3*1**3?

Question No# : 14 out of 20



What will be the value of the following Python expression?

4+2**5//10

Option A. 3
Option B. 7
Option C. 77
Option D. 0
True Answer B

Explanation :
The order of precedence is: **, //, +. The expression 4+2**5//10 is evaluated as 4+32//10, which is equal to 4+3 = 7. Hence the result of the expression shown above is 7.

What will be the value of the following Python expression?

4+2**5//10

Question No# : 15 out of 20



What will be the output of the following Python code snippet?

for i in [1, 2, 3, 4][::-1]:      print (i)

Option A. 1 2 3 4
Option B. 4 3 2 1
Option C. error
Option D. none of the mentioned
True Answer B

Explanation :
[::-1] reverses the list.

What will be the output of the following Python code snippet?

for i in [1, 2, 3, 4][::-1]:      print (i)

Question No# : 16 out of 20



While statements gets executed at least once

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer B

Explanation :

While statements gets executed at least once

Question No# : 17 out of 20

What will be the output of the following Python code?

    x = "abcdef"  i = "i"  while i in x:      print(i, end=" ")

Option A. no output
Option B. i i i i i i …
Option C. a b c d e f
Option D. abcdef
True Answer A

Explanation :
“i” is not in “abcdef”.

What will be the output of the following Python code?

    x = "abcdef"  i = "i"  while i in x:      print(i, end=" ")

Question No# : 18 out of 20



What will be the output of the following Python code?

  i = 1  while True:      if i%0O7 == 0:          break      print(i)      i += 1

Option A. 1 2 3 4 5 6
Option B. 1 2 3 4 5 6 7
Option C. error
Option D. none of the mentioned
True Answer A

Explanation :
Control exits the loop when i becomes 7.

What will be the output of the following Python code?

  i = 1  while True:      if i%0O7 == 0:          break      print(i)      i += 1

Question No# : 19 out of 20



What will be the output of the following Python code?

    i = 1  while True:      if i%2 == 0:          break      print(i)      i += 2

Option A. 1
Option B. 1 2
Option C. 1 2 3 4 5 6 …
Option D. 1 3 5 7 9 11 …
True Answer D

Explanation :
The loop does not terminate since i is never an even number.

What will be the output of the following Python code?

    i = 1  while True:      if i%2 == 0:          break      print(i)      i += 2

Question No# : 20 out of 20




CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Website development Company in Allahabad