





















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






















Answer: C) # comment Rationale: Python uses the hash symbol (#) for single-line comments. 10.What does input() function return? A) int B) float C) string D) boolean Answer: C) string Rationale: The input() function always returns user input as a string, regardless of what is entered. 11.Which keyword is used for conditional branching? A) loop B) if C) switch D) case Answer: B) if Rationale: Python uses if for conditional execution of code blocks. 12.What is the result of 10 // 3? A) 3. B) 3 C) 4 D) 3. Answer: B) 3 Rationale: The // operator performs floor division, returning the largest integer less than or equal to the result.
13.Which of these is a valid variable name? A) 1variable B) variable_ C) variable- 1 D) variable 1 Answer: B) variable_ Rationale: Variable names can include letters, numbers, and underscores but cannot start with a number or contain spaces/hyphens. 14.What is the output of bool(0)? A) True B) False C) None D) Error Answer: B) False Rationale: In Python, 0 is considered falsy, so converting it to boolean returns False. 15.Which loop executes at least once? A) for B) while C) do-while D) None Answer: D) None Rationale: Python does not have a built-in do-while loop; both for and while may not execute at all depending on condition. 16.What is the output of type([])? A) tuple B) list
Rationale: The .lower() method converts all characters in a string to lowercase. 20.Which symbol is used for equality comparison? A) = B) == C) != D) => Answer: B) == Rationale: == checks whether two values are equal, while = is assignment. 21.What does range(3) produce? A) 1,2, B) 0,1, C) 0,1,2, D) 1, Answer: B) 0,1, Rationale: range(3) generates numbers starting from 0 up to but not including 3. 22.Which data type is ordered and mutable? A) tuple B) set C) list D) frozenset Answer: C) list Rationale: Lists maintain order and can be modified after creation.
23.What does print(2 == 2.0) return? A) True B) False C) Error D) None Answer: A) True Rationale: Python compares numeric values across types and considers 2 equal to 2.0. 24.Which keyword is used to exit a loop? A) stop B) exit C) break D) return Answer: C) break Rationale: break terminates the loop immediately when executed. 25.What is output of 5 % 2? A) 2 B) 1 C) 0 D) 2. Answer: B) 1 Rationale: The modulus operator returns remainder after division. 26.What does not True evaluate to? A) True B) False C) None D) Error
B) print C) show D) display Answer: B) print Rationale: print() outputs data to the console. 31.What does str(100) return? A) 100 B) "100" C) 100. D) Error Answer: B) "100" Rationale: str() converts numbers to string format. 32.Which is a valid Python literal? A) True B) true C) TRUE D) yes Answer: A) True Rationale: Boolean literals in Python are case-sensitive: True and False. 33.What is output of 2 + 3 * 2? A) 10 B) 8 C) 7 D) 12 Answer: C) 8 Rationale: Multiplication has higher precedence than addition.
34.Which keyword defines loop iteration? A) for B) iterate C) loop D) each Answer: A) for Rationale: for is used for iterating over sequences. 35.What is type of {}? A) list B) tuple C) dictionary D) set Answer: C) dictionary Rationale: Empty curly braces define an empty dictionary. 36.Which function checks data type? A) check() B) type() C) isinstanceonly() D) class() Answer: B) type() Rationale: type() returns the data type of an object. 37.What is output of "a" + "b"? A) ab B) a b C) error D) a+b
B) try/except C) error D) handle Answer: B) try/except Rationale: Python uses try/except blocks to manage runtime errors. 42.What does abs(-5) return? A) - 5 B) 5 C) 0 D) error Answer: B) 5 Rationale: abs() returns the absolute (positive) value of a number. 43.What is output of min([3,1,2])? A) 3 B) 1 C) 2 D) error Answer: B) 1 Rationale: min() returns the smallest value in a sequence. 44.Which keyword creates a class? A) object B) class C) struct D) define Answer: B) class Rationale: class defines a new object blueprint in Python.
45.What is output of max([1,5,3])? A) 1 B) 3 C) 5 D) error Answer: C) 5 Rationale: max() returns the largest value in a sequence. 46.What does round(2.6) return? A) 2 B) 3 C) 2. D) error Answer: B) 3 Rationale: round() rounds to the nearest integer. 47.Which keyword is used to return value from function? A) break B) exit C) return D) yieldonly Answer: C) return Rationale: return sends a value back from a function. 48.What is output of 1 == 1 and 2 == 3? A) True B) False C) None D) Error Answer: B) False
B) append() C) insertonly() D) push() Answer: B) append() Rationale: append() adds an item at the end of a list. 53.What is output of bool("")? A) True B) False C) None D) Error Answer: B) False Rationale: Empty string is considered falsy. 54.Which keyword is used for module import? A) include B) using C) import D) require Answer: C) import Rationale: import loads external modules. 55.What is output of list("abc")? A) abc B) ['a','b','c'] C) ['abc'] D) error Answer: B) ['a','b','c'] Rationale: String is split into characters when converted to list.
56.Which operator checks identity? A) == B) is C) equals D) === Answer: B) is Rationale: is checks if two variables reference the same object. 57.What is output of 10 > 5 and 3 < 1? A) True B) False C) None D) Error Answer: B) False Rationale: Second condition is False, so AND evaluates False. 58.Which function returns length? A) size() B) len() C) length() D) count() Answer: B) len() Rationale: len() returns number of items in a container. 59.What is correct dictionary syntax? A) [a:1] B) (a:1) C) {a:1} D)
B) break C) loop D) continue Answer: C) loop Rationale: loop is not a Python keyword. 64.What does str.lower() do? A) uppercase B) lowercase C) reverse D) delete Answer: B) lowercase Rationale: Converts string to lowercase. 65.What is output of [1,2] + [3,4]? A) [1,2,3,4] B) [4,6] C) error D) [1,5] Answer: A) [1,2,3,4] Rationale: List concatenation merges lists. 66.Which statement skips iteration? A) break B) pass C) continue D) stop Answer: C) continue Rationale: continue skips current loop iteration.
67.What is output of type(True)? A) int B) bool C) str D) float Answer: B) bool Rationale: True is a boolean type. 68.Which symbol starts docstring? A) # B) // C) """ D)