




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This certification assesses knowledge of Python programming. Topics include data types, control structures, functions, object-oriented programming, libraries, and basic scripting for automation. Candidates gain skills to develop Python-based applications and solve programming problems effectively.
Typology: Exams
1 / 161
This page cannot be seen from the preview
Don't miss anything!





























































































Question 1. What will happen if you do not use consistent indentation in a block of Python code? A) The code will run but may produce wrong results B) The code will be ignored C) Python will raise an IndentationError D) Python will automatically fix the indentation Answer: C Explanation: Python requires consistent indentation to define code blocks; inconsistent indentation will result in an IndentationError. Question 2. Which character(s) start a single-line comment in Python? A) // B) #
Answer: B Explanation: Single-line comments in Python start with the hash (#) character. Question 3. How do you execute a Python script file named "script.py" in the terminal? A) python script.py B) run script.py C) start script.py D) execute script.py Answer: A
A) _counter B) age C) 2age D) name Answer: C Explanation: Variable names cannot start with a number. Question 6. What is the result of 3 + 2 * 2? A) 10 B) 7 C) 9 D) 12 Answer: B
Explanation: Multiplication has higher precedence; 2*2=4, then 3+4=7. Question 7. Which function is used to change the type of a value to a string? A) cast() B) str() C) string() D) toString() Answer: B Explanation: str() converts a value to its string representation. Question 8. What will print(type(5.0)) output? A) <class 'int'>
Explanation: // performs integer (floor) division, discarding the decimal part. Question 10. What is the output of print(4 ** 2)? A) 8 B) 16 C) 6 D) 4 Answer: B Explanation: ** is the exponentiation operator; 4**2 means 4 to the power of 2, which is 16. Question 11. Which of the following is a Boolean value in Python?
B) True C) Yes D) 1 Answer: B Explanation: The Boolean values are True and False (case-sensitive). Question 12. What is the result of bool("") in Python? A) True B) False C) None D) Error Answer: B
B) python C) Python D) P Y T H O N Answer: A Explanation: upper() returns a new string with all letters capitalized. Question 15. How do you get user input as a string in Python 3? A) input() B) raw_input() C) gets() D) scan() Answer: A Explanation: input() returns user input as a string in Python 3.
Question 16. What will print("apple".replace("a", "o")) display? A) opple B) apple C) oapple D) opplo Answer: A Explanation: replace() replaces all instances of "a" with "o", resulting in 'opple'. Question 17. Which string method removes whitespace from both ends of a string? A) trim()
Question 19. How do you format a string using an f-string? A) "Hello {name}" B) f"Hello {name}" C) format("Hello {name}") D) "Hello".format(name) Answer: B Explanation: f-strings prefix the string with 'f' to allow inline variable interpolation. Question 20. Which of the following expressions gives the last character in the string s? A) s[0]
B) s[-1] C) s[1] D) s[len(s)] Answer: B Explanation: Negative index - 1 accesses the last character of a string. Question 21. What is the result of "hello world".split()? A) ["hello", "world"] B) "hello", "world" C) ['hello world'] D) ('hello', 'world') Answer: A Explanation: split() splits the string at whitespace into a list of words.
Answer: A Explanation: The + operator concatenates lists. Question 24. Which method adds an item to the end of a list? A) add() B) append() C) insert() D) push() Answer: B Explanation: append() adds an element to the end of a list.
Question 25. What is the result of: [1,2,3].pop()? A) 1 B) 2 C) 3 D) [1,2,3] Answer: C Explanation: pop() removes and returns the last element of the list. Question 26. What does the method list.sort() do? A) Returns a sorted list B) Sorts the list in place C) Sorts a copy of the list D) Reverses the list
A) A new list with references to the original elements B) A completely independent copy C) A reversed list D) A sorted list Answer: A Explanation: A shallow copy creates a new list object, but elements are references to the same objects as in the source. Question 29. Which of the following creates a list comprehension of squares from 0 to 4? A) [ii for i in range(5)] B) [i^2 for i in 5] C) list(ii for i in range(5))
D) (ii for i in range(5)) Answer: A Explanation: [ii for i in range(5)] uses list comprehension to create a list of squares. Question 30. What is the result of tuple("abc")? A) ("abc") B) ['a', 'b', 'c'] C) ('a', 'b', 'c') D) ('abc',) Answer: C Explanation: tuple("abc") creates a tuple with each character as an element.