What is the output of print(2 + 3 * 4)?
Correct answer:
A) 14
Explanation: Multiplication precedes addition, so 3 * 4 = 12 is added to 2, giving 14.
What is the output of print(2 + 3 * 4)?
Correct answer:
A) 14
Explanation: Multiplication precedes addition, so 3 * 4 = 12 is added to 2, giving 14.
What is the output of print(10 // 3)?
Correct answer:
B) 3
Explanation: Floor division discards the fractional part, so 10 // 3 evaluates to 3.
What is the output of print(10 % 3)?
Correct answer:
C) 1
Explanation: The modulo operator returns the remainder of 10 divided by 3, which is 1.
What is the output of print(len('automation'))?
Correct answer:
D) 10
Explanation: The word 'automation' has 10 characters, so len returns 10.
What is the output of print('ab' * 3)?
Correct answer:
A) ababab
Explanation: Multiplying a string by an integer repeats it, so 'ab' * 3 produces 'ababab'.
What does 'Hello'[1] return?
Correct answer:
B) 'e'
Explanation: Zero-based indexing means index 1 is the second character, 'e'.
What does 'Python'[-1] return?
Correct answer:
C) 'n'
Explanation: Index -1 refers to the last character, which is 'n'.
What is the output of print(bool(0))?
Correct answer:
D) False
Explanation: The integer 0 is falsy, so bool(0) returns False.
What is the output of print(bool('hello'))?
Correct answer:
A) True
Explanation: A non-empty string is truthy, so bool('hello') returns True.
What does list('abc') produce?
Correct answer:
B) ['a', 'b', 'c']
Explanation: Passing a string to list() creates a list of its individual characters.
What is the output of print(list(range(2, 5)))?
Correct answer:
C) [2, 3, 4]
Explanation: range(2, 5) produces 2, 3, 4, stopping before 5, and list() collects them.
What does 'a,b,c'.split(',') return?
Correct answer:
D) ['a', 'b', 'c']
Explanation: split(',') divides the string at each comma, returning the list ['a', 'b', 'c'].
What does ' '.join(['a', 'b', 'c']) return?
Correct answer:
A) 'a b c'
Explanation: join concatenates the list elements using a space separator, producing 'a b c'.
What is the result of 'Hello'.replace('l', 'L')?
Correct answer:
B) 'HeLLo'
Explanation: replace substitutes every 'l' with 'L', giving 'HeLLo'.
What does {1, 2, 2, 3} evaluate to as a set?
Correct answer:
C) {1, 2, 3}
Explanation: A set removes duplicates automatically, so the repeated 2 is stored only once, giving {1, 2, 3}.
What does dict(a=1, b=2) create?
Correct answer:
D) {'a': 1, 'b': 2}
Explanation: dict with keyword arguments creates a dictionary mapping 'a' to 1 and 'b' to 2.
What is the output of print(sum([1, 2, 3, 4]))?
Correct answer:
A) 10
Explanation: The sum() function adds all elements of the list: 1 + 2 + 3 + 4 = 10.
What is the output of print(max([3, 7, 2, 9, 5]))?
Correct answer:
B) 9
Explanation: max() returns the largest element, which is 9.
What is the output of print(min([3, 7, 2, 9, 5]))?
Correct answer:
C) 2
Explanation: min() returns the smallest element, which is 2.
What is the output of print(sorted([3, 1, 2]))?
Correct answer:
D) [1, 2, 3]
Explanation: sorted() returns a new list in ascending order: [1, 2, 3].
What does 'HELLO'.lower() return?
Correct answer:
A) 'hello'
Explanation: The lower() method converts all characters to lowercase, returning 'hello'.
What is the output of print(abs(-7))?
Correct answer:
B) 7
Explanation: abs() returns the absolute value, converting -7 to 7.
What does round(3.567, 1) return?
Correct answer:
C) 3.6
Explanation: round(3.567, 1) rounds to one decimal place, giving 3.6.
What is the output of print(type(5))?
Correct answer:
D) <class 'int'>
Explanation: type(5) returns the type object for integers, displayed as <class 'int'>.
What is the result of int('10') + 5?
Correct answer:
A) 15
Explanation: int('10') converts the string to 10, and adding 5 gives 15.
What is the result of str(10) + '5'?
Correct answer:
B) '105'
Explanation: str(10) is '10', and concatenating '5' gives the string '105'.
What does ' data '.strip() return?
Correct answer:
C) 'data'
Explanation: strip() removes leading and trailing whitespace, returning 'data'.
What is the output of print(3 > 2 and 5 > 4)?
Correct answer:
D) True
Explanation: Both comparisons are true, and the and of two true values is True.
What is the output of print(3 > 5 or 2 < 4)?
Correct answer:
A) True
Explanation: The first comparison is false but the second is true, and or returns True if either operand is true.
What is the output of print(not True)?
Correct answer:
B) False
Explanation: The not operator negates True, producing False.
What does 'automation'.startswith('auto') return?
Correct answer:
C) True
Explanation: startswith checks the beginning of the string, and 'automation' does start with 'auto', so it returns True.
What does 'report.txt'.endswith('.txt') return?
Correct answer:
D) True
Explanation: endswith checks the end of the string, and the filename ends with '.txt', so it returns True.
What is the output of print('abc'.upper())?
Correct answer:
A) 'ABC'
Explanation: upper() converts all characters to uppercase, returning 'ABC'.
What does list(range(0, 10, 2)) produce?
Correct answer:
B) [0, 2, 4, 6, 8]
Explanation: The step of 2 produces every other number starting at 0 up to but not including 10: [0, 2, 4, 6, 8].
What is the output of print(len([1, [2, 3], 4]))?
Correct answer:
C) 3
Explanation: The list has three top-level elements: 1, the sublist [2, 3], and 4, so len returns 3.
What does 'Hello World'.split() return with no argument?
Correct answer:
D) ['Hello', 'World']
Explanation: split() with no argument splits on whitespace, giving ['Hello', 'World'].
What is the output of print(2 ** 5)?
Correct answer:
A) 32
Explanation: The exponentiation operator raises 2 to the 5th power, giving 32.
What does a Python dictionary's get('x', 0) return if 'x' is not a key?
Correct answer:
B) 0
Explanation: get returns the specified default (0 here) when the key is absent, avoiding a KeyError.
What is the output of print('yes' if 5 > 3 else 'no')?
Correct answer:
C) yes
Explanation: Since 5 > 3 is true, the conditional expression returns 'yes'.
What does the expression [x*x for x in range(4)] produce?
Correct answer:
D) [0, 1, 4, 9]
Explanation: The comprehension squares each of 0, 1, 2, 3, giving [0, 1, 4, 9].
What is the output of print('a' in 'automation')?
Correct answer:
A) True
Explanation: The in operator checks membership, and 'a' does appear in 'automation', so it returns True.
What does the float() function do with '3.14'?
Correct answer:
B) Converts it to the number 3.14
Explanation: float('3.14') converts the numeric string to the floating-point number 3.14.
What is the output of print(list(reversed([1, 2, 3])))?
Correct answer:
C) [3, 2, 1]
Explanation: reversed() returns an iterator in reverse order, and list() collects it as [3, 2, 1].
What does 'data.csv'.split('.')[-1] return?
Correct answer:
D) 'csv'
Explanation: Splitting on '.' gives ['data', 'csv'], and index -1 selects the last element, 'csv'.
What is the output of print(5 == 5.0)?
Correct answer:
A) True
Explanation: Python compares numeric values, and 5 equals 5.0, so the result is True.
What does the count() list method return?
Correct answer:
B) The number of times a value appears in the list
Explanation: list.count(value) returns how many times the given value appears in the list.
What does 'Hello'.find('l') return?
Correct answer:
C) 2
Explanation: find returns the index of the first occurrence of 'l', which is at position 2.
What is the output of print(int(7.9))?
Correct answer:
D) 7
Explanation: Converting a float to int truncates toward zero, so int(7.9) is 7.
What does the pop() method do to a list?
Correct answer:
A) Removes and returns the last item by default
Explanation: list.pop() removes and returns the last element by default, or the element at a given index if specified.
What single practice most improves the reliability of a Python automation script?
Correct answer:
B) Combining input validation, error handling, and logging
Explanation: Validating inputs, handling errors gracefully, and logging results together make an automation script robust and reliable when run unattended.
If this exam is giving you a hard time, let us be your helping hand. Contact us, and we'll provide the assistance you need to pass and move forward.