OBJECTIVE ASSESSMENT WITH
ACCURATE SOLUTIONS VERIFIED 2026
Question 1
You want to calculate the human-equivalent age of a pig, knowing one pig
year equals five human years. You are provided a module pigAge with a
function pigAge_converter(). Which of the following correctly converts the
input pig age to human years?
A) pig_age = int(input()); print(pig_age * 5)
B) import pigAge; pig_age = int(input());
print(pigAge.pigAge_converter(pig_age))
C) pig_age = input(); print(pig_age + 5)
D) pigAge_converter(input())
Answer: B
Question 2
You have a list of frameworks: ["Django", "Flask", "CherryPy", "Bottle",
"Web2Py", "TurboGears"]. You want to safely get the element by an index
entered by the user and print “Error” if the index is invalid. Which code
correctly implements this?
A) print(frameworks[int(input())])
B) try: print(frameworks[int(input())]); except: print("Error")
C) index = input(); print(frameworks[index])
D) frameworks.get(input())
Answer: B
,Question 3
You need to read a CSV file and create a dictionary where the even-indexed
columns are keys and odd-indexed columns are values. Which snippet
accomplishes this?
A) import csv; data = csv.reader(open("file.csv")); print(dict(data))
B) import csv; with open("file.csv") as f: data = [row for row in
csv.reader(f)]; print({row[i]: row[i+1] for i in range(0,len(row),2)})
C) with open("file.csv") as f: print(f.readlines())
D) csv.read("file.csv")
Answer: B
Question 4
Which of the following correctly checks whether the factorial of a number is
greater than 100?
A) import math; fact = math.factorial(int(input())); print(fact > 100)
B) fact = int(input()); print(fact*fact > 100)
C) import math; print(math.factorial(input()) > 100)
D) import math; print(fact > math.factorial(100))
Answer: A
Question 5
,You want to format a student ID number 123456789 as 123-45-6789. Which
Python code snippet works correctly?
A) id = "123456789"; print(id[0:3] + "-" + id[3:5] + "-" + id[5:])
B) id = 123456789; print(id[0:3] + "-" + id[3:5] + "-" + id[5:])
C) id = "123456789"; print(id[:3], id[3:5], id[5:])
D) id = 123456789; print(str(id).join("-"))
Answer: A
Question 6
Which of the following is the correct syntax to define a function in Python
that accepts two parameters and returns their sum?
A) def add(a, b): return a + b
B) function add(a, b) { return a + b }
C) add(a, b) = a + b
D) def add: return a + b
Answer: A
Question 7
What is the output of the following code?
x = [1, 2, 3, 4] print(x[1:3])
A) [1, 2]
B) [2, 3]
C) [2, 3, 4]
D) [1, 2, 3]
, Answer: B
Question 8
Which of the following statements about Python dictionaries is correct?
A) Keys in a dictionary can be lists.
B) Dictionaries are mutable and unordered collections of key-value pairs.
C) Dictionaries maintain insertion order in all Python versions.
D) Values in a dictionary must be unique.
Answer: B
Question 9
You want to check if a number entered by the user is even or odd. Which
code snippet works correctly?
A) num = int(input()); print("Even" if num % 2 == 0 else "Odd")
B) num = int(input()); print("Even" if num / 2 == 0 else "Odd")
C) num = input(); print(num % 2 == 0)
D) num = int(input()); print("Odd" if num % 2 == 0 else "Even")
Answer: A