Python MCQs with answers Page - 5

Dear candidates you will find MCQ questions of Python here. Learn these questions and prepare yourself for coming examinations and interviews. You can check the right answer of any question by clicking on any option or by clicking view answer button.
Share your questions by clicking Add Question

R

Ram Sharma • 193.86K Points
Coach

Q. What is the output of the following piece of code?

Code:
#mod1
def change(a):
b=[x*2 for x in a]
print(b)
#mod2
def change(a):
b=[x*x for x in a]
print(b)
from mod1 import change
from mod2 import change
#main
s=[1,2,3]
change(s)
  • (A) [2,4,6].
  • (B) [1,4,9].
  • (C) [2,4,6].
  • (D) There is a name clash

R

Ram Sharma • 193.86K Points
Coach

Q. What is the output of the following program?

Code:
tday=datetime.date.today() print(tday.month())
  • (A) August
  • (B) Aug
  • (C) 08
  • (D) 8

R

Ram Sharma • 193.86K Points
Coach

Q. Which of the following formatting options can be used in order to add „n? blank spaces after a given string „S??

  • (A) print(“-ns”%S)
  • (B) print(“-ns”%S)
  • (C) print(“%ns”%S)
  • (D) print(“%-ns”%S)

R

Ram Sharma • 193.86K Points
Coach

Q. What is the output of the following program?

Code:
f = None
for i in range (5):
with open("data.txt", "w") as f:
if i > 2:
break
print(f.closed)
  • (A) True
  • (B) False
  • (C) None
  • (D) Error

R

Ram Sharma • 193.86K Points
Coach

Q. To read the entire remaining contents of the file as a string from a file object infile, we use

  • (A) infile.read(2)
  • (B) infile.read()
  • (C) infile.readline()
  • (D) infile.readlines()

R

Ram Sharma • 193.86K Points
Coach

Q. Suppose t = (1, 2, 4, 3), which of the following is incorrect?

  • (A) print(t[3])
  • (B) t[3] = 45
  • (C) print(max(t))
  • (D) print(len(t))

S

Shivam • 8.86K Points
Tutor III

Q. Who developed Python Programming Language?

  • (A) Wick van Rossum
  • (B) Rasmus Lerdorf
  • (C) Guido van Rossum
  • (D) Niene Stom

S

Shivam • 8.86K Points
Tutor III

Q. Which type of Programming does Python support?

  • (A) object-oriented programming
  • (B) structured programming
  • (C) functional programming
  • (D) all of the mentioned

S

Shivam • 8.86K Points
Tutor III

Q. Is Python case sensitive when dealing with identifiers?

  • (A) no
  • (B) yes
  • (C) machine dependent
  • (D) none

S

Shivam • 8.86K Points
Tutor III

Q. Which of the following is the correct extension of the Python file?

  • (A) .python
  • (B) .pl
  • (C) .py
  • (D) .p

Loding content...

Download our easy to use, user friendly Android App from Play Store. And learn MCQs with one click.

Image

Login

Forgot username? click here

Forgot password? Click here

Don't have account? Register here.