Q. Program code making use of a given module is called a ______ of the module.

  • (A) Client
  • (B) Docstring
  • (C) Interface
  • (D) Modularity
πŸ’¬ Discuss
βœ… Correct Answer: (A) Client

Q. What is the output of the following piece of 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
πŸ’¬ Discuss
βœ… Correct Answer: (D) There is a name clash

Q. What is the output of the following program? tday=datetime.date.today() print(tday.month())

  • (A) August
  • (B) Aug
  • (C) 08
  • (D) 8
πŸ’¬ Discuss
βœ… Correct Answer: (D) 8

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)
πŸ’¬ Discuss
βœ… Correct Answer: (D) print(“%-ns”%S)

Q. What is the output of the following program?
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
πŸ’¬ Discuss
βœ… Correct Answer: (A) True

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()
πŸ’¬ Discuss
βœ… Correct Answer: (B) infile.read()

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))
πŸ’¬ Discuss
βœ… Correct Answer: (B) t[3] = 45

Jump to