- Which keyword is used to import a module in Python?
View Answer
Correct answer: B — import
- What will be printed?
1 import math 2 print(math.sqrt(16)) View Answer
Correct answer: A — 4
- Which of the following is used to import specific function from module?
View Answer
Correct answer: B — from module import function
- What is the output of print(math.pi)?
View Answer
Correct answer: B — 3.141592653589793
- Which of the following is used to import module with alias?
View Answer
Correct answer: A — import module as alias
- What will be printed?
1 import random 2 print(random.randint(1,3)) View Answer
Correct answer: D — Any of the above
- Which of the following is used to import all functions from module?
View Answer
Correct answer: B — from module import *
- What is the output of print(len(dir(math)))?
View Answer
Correct answer: A — Number of attributes in math module
- Which of the following is used to reload a module?
View Answer
Correct answer: B — importlib.reload(module)
- What will be printed?
1 import os 2 print(os.name) View Answer
Correct answer: A — posix or nt
- Which of the following is used to get current working directory?
View Answer
Correct answer: A — os.getcwd()
- What is the output of print(sys.version)?
View Answer
Correct answer: A — Python version string
- Which of the following is used to exit program?
View Answer
Correct answer: D — Both A and C
- What will be printed?
1 import datetime 2 print(datetime.date.today().year) View Answer
Correct answer: A — Current year
- Which of the following is used to import JSON module?
View Answer
Correct answer: A — import json
- What is the output of print(json.dumps({"Eduinq":1}))?
View Answer
Correct answer: A — {"Eduinq":1}
- Which of the following is used to import CSV module?
View Answer
Correct answer: A — import csv
- What will be printed?
1 import csv 2 print(type(csv)) View Answer
Correct answer: A — <class 'module'>
- Which of the following is used to import custom module?
View Answer
Correct answer: C — Both A and B
- What is the output of print(__name__)?
View Answer
Correct answer: A — __main__
- Which of the following is used to check module location?
View Answer
Correct answer: A — module.__file__
- What will be printed?
1 import math as m 2 print(m.factorial(5)) View Answer
Correct answer: A — 120
- Which of the following is used to import specific attributes?
View Answer
Correct answer: A — from module import attr1, attr2
- What is the output of print(len(dir(os)))?
View Answer
Correct answer: A — Number of attributes in os module
- Which of the following is used to import time module?
View Answer
Correct answer: A — import time
- What will be printed?
1 import time 2 print(time.sleep(0)) View Answer
Correct answer: A — None
- Which of the following is used to import random module?
View Answer
Correct answer: A — import random
- What is the output of print(type(random))?
View Answer
Correct answer: A — <class 'module'>
- Which of the following is used to import math module?
View Answer
Correct answer: A — import math
- What will be printed?
1 import math 2 print(math.pow(2,3)) View Answer
Correct answer: A — 8.0
- Which of the following is used to import os module?
View Answer
Correct answer: A — import os
- What is the output of print(os.getcwd())?
View Answer
Correct answer: A — Current working directory
- Which of the following is used to import sys module?
View Answer
Correct answer: A — import sys
- What will be printed?
1 import sys 2 print(sys.platform) View Answer
Correct answer: A — Platform name
- Which of the following is used to import datetime module?
View Answer
Correct answer: A — import datetime
- What is the output of print(datetime.datetime.now().year)?
View Answer
Correct answer: A — Current year
- Which of the following is used to import re module?
View Answer
Correct answer: A — import re
- What will be printed?
1 import re 2 print(re.match("Edu", "Eduinq").group()) View Answer
Correct answer: A — Edu
- Which of the following is used to import functools module?
View Answer
Correct answer: A — import functools
- What is the output of print(functools.reduce(lambda x,y:x+y,[1,2,3]))?
View Answer
Correct answer: A — 6
- Which of the following is used to import itertools module?
View Answer
Correct answer: A — import itertools
- What will be printed?
1 import itertools 2 print(list(itertools.permutations([1,2],2))) View Answer
Correct answer: A — [(1,2),(2,1)]
- Which of the following is used to import collections module?
View Answer
Correct answer: A — import collections
- What is the output of print(collections.Counter("Eduinq"))?
View Answer
Correct answer: A — Counter({'E':1,'d':1,'u':1,'i':1,'n':1,'q':1})
- Which of the following is used to import statistics module?
View Answer
Correct answer: A — import statistics
- What will be printed?
1 import statistics 2 print(statistics.mean([1,2,3])) View Answer
Correct answer: A — 2
- Which of the following is used to import decimal module?
View Answer
Correct answer: A — import decimal
- What is the output of print(decimal.Decimal('0.1')+decimal.Decimal('0.2'))?
View Answer
Correct answer: A — 0.3
- Which of the following is used to import fractions module?
View Answer
Correct answer: A — import fractions
- What will be printed?
1 import fractions 2 print(fractions.Fraction(1,3)+fractions.Fraction(1,6)) View Answer
Correct answer: A — 1/2