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

OPERATORS EXPRESSIONS AND PYTHON STATEMENTS

00:00:00

The continue and break statement have same effect

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

Explanation :

The continue and break statement have same effect

Question No# : 01 out of 20

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

for i in ''.join(reversed(list('abcd'))):      print (i)

Option A. a b c d
Option B. d c b a
Option C. error
Option D. none of the mentioned
True Answer B

Explanation :
‘ ‘.join(reversed(list(‘abcd’))) reverses a string.

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

for i in ''.join(reversed(list('abcd'))):      print (i)

Question No# : 02 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# : 03 out of 20

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

  x = 'abcd'  for i in range(len(x)):      x[i].upper()  print (x)

Option A. abcd
Option B. ABCD
Option C. error
Option D. none of the mentioned
True Answer A

Explanation :
Changes do not happen in-place, rather a new instance of the string is returned.

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

  x = 'abcd'  for i in range(len(x)):      x[i].upper()  print (x)

Question No# : 04 out of 20



What will be the output of the following Python statement?

>>>"a"+"bc"

Option A. a
Option B. bc
Option C. bca
Option D. abc
True Answer D

Explanation :
+ operator is concatenation operator.

What will be the output of the following Python statement?

>>>"a"+"bc"

Question No# : 05 out of 20



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

  x = 2  for i in range(x):      x -= 2      print (x)

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

Explanation :
The loop is entered twice.

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

  x = 2  for i in range(x):      x -= 2      print (x)

Question No# : 06 out of 20



What will be the output of the following Python code?

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

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

Explanation :
The else part is executed when the condition in the while statement is false.

What will be the output of the following Python code?

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

Question No# : 07 out of 20



Which operator is also called as Comparative operator?

Option A. Arithmetic
Option B. Relational
Option C. Logical
Option D. Assignment
True Answer B

Explanation :

Which operator is also called as Comparative operator?

Question No# : 08 out of 20

What will be the output of the following Python code?

  x = 123  for i in x:      print(i)

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

Explanation :
Objects of type int are not iterable.

What will be the output of the following Python code?

  x = 123  for i in x:      print(i)

Question No# : 09 out of 20



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

not(10<20) and not(10>30)

Option A. True
Option B. False
Option C. Error
Option D. No output
True Answer B

Explanation :
The expression not(10<20) returns false. The expression not(10>30) returns true. The and operation between false and true returns false. Hence the output is false.

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

not(10<20) and not(10>30)

Question No# : 10 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# : 11 out of 20



What will be the output of the following Python code?

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

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

Explanation :
SyntaxError, there shouldn’t be a space between + and = in +=.

What will be the output of the following Python code?

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

Question No# : 12 out of 20



What will be the output of the following Python code?

  x = 'abcd'  for i in x:      print(i)      x.upper()

Option A. a B C D
Option B. a b c d
Option C. A B C D
Option D. error
True Answer B

Explanation :
Changes do not happen in-place, rather a new instance of the string is returned.

What will be the output of the following Python code?

  x = 'abcd'  for i in x:      print(i)      x.upper()

Question No# : 13 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# : 14 out of 20



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

  x = 'abcd'  for i in range(len(x)):      i.upper()  print (x)

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

Explanation :
Objects of type int have no attribute upper().

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

  x = 'abcd'  for i in range(len(x)):      i.upper()  print (x)

Question No# : 15 out of 20



Checking condition in python can be done by using the if-else statement

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

Explanation :

Checking condition in python can be done by using the if-else statement

Question No# : 16 out of 20

What will be the output of the following Python code?

for i in range(10):      if i == 5:          break      else:          print(i)  else:      print("Here")

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

Explanation :
The else part is executed if control doesn’t break out of the loop.

What will be the output of the following Python code?

for i in range(10):      if i == 5:          break      else:          print(i)  else:      print("Here")

Question No# : 17 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# : 18 out of 20



What will be the output of the following Python code?

  x = ['ab', 'cd']  for i in x:      x.append(i.upper())  print(x)

Option A. [‘AB’, ‘CD’]
Option B. [‘ab’, ‘cd’, ‘AB’, ‘CD’]
Option C. [‘ab’, ‘cd’]
Option D. none of the mentioned
True Answer D

Explanation :
The loop does not terminate as new elements are being added to the list in each iteration.

What will be the output of the following Python code?

  x = ['ab', 'cd']  for i in x:      x.append(i.upper())  print(x)

Question No# : 19 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# : 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