












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!













a) Function
b) Variable
c) Loop
d) Operator
CORRECT ANSWER: b) Variable
a) // This is a comment
b) This is a comment
c) # This is a comment
d) /* This is a comment */
CORRECT ANSWER: c) # This is a comment
a) int
b) float
c) str
d) bool
CORRECT ANSWER: b) float
a) 5
b) 5.
c) 6
d) Error
CORRECT ANSWER: b) 5.5 (Python performs implicit type conversion)
a) print()
b) get()
c) input()
d) scan()
CORRECT ANSWER: c) input()
a) string()
b) int()
c) float()
CORRECT ANSWER: b) end=' '
a) A tool that converts Python code to Java.
b) A program that executes Python code line by line.
c) A text editor for writing code.
d) A compiler that creates an executable file.
CORRECT ANSWER: b) A program that executes Python code line by line.
a) A variable that holds numbers.
b) A sequence of characters enclosed in quotes.
c) A type of loop.
d) A built-in function.
CORRECT ANSWER: b) A sequence of characters enclosed in quotes.
a) H
b) e
c) l
d) o
CORRECT ANSWER: b) e (Indexing in Python starts at 0)
a) The number of times 'x' appears.
b) The index of the first occurrence of 'x'.
c) The index of the last occurrence of 'x'.
d) An error if 'x' is not found.
CORRECT ANSWER: b) The index of the first occurrence of 'x'.
a) A tab space
b) A new line
c) A backslash
d) The end of a string
CORRECT ANSWER: b) A new line
d) 1
CORRECT ANSWER: b) 3 (// is the floor division operator)
a) 3
b) 3.
c) 1
d) 0
CORRECT ANSWER: c) 1 (% is the modulus operator, giving the remainder)
a) ^
b) ``
c) *
d) ^^
CORRECT ANSWER: b) ``
a) 7
b) 9
c) 5
d) 6
CORRECT ANSWER: b) 9 (Parentheses have the highest precedence)
a) -7.
b) 7.
c) -
d) 8
CORRECT ANSWER: b) 7.5 (Absolute value removes the negative sign)
a) =!
b) <
c) !=
d) <
CORRECT ANSWER: c) !=
a) True
b) False
c) None
d) Error
c) Set
d) Dictionary
CORRECT ANSWER: c) Set
a) my_list.add(5)
b) my_list.insert(5)
c) my_list.append(5)
d) my_list.put(5)
CORRECT ANSWER: c) my_list.append(5)
a) The set becomes {1, 2, 2, 3}.
b) The set remains {1, 2, 3}.
c) An error occurs.
d) The set becomes {1, 2, 3, 2}.
CORRECT ANSWER: b) The set remains {1, 2, 3}. (Sets contain only unique elements)
a) person[0]
b) person.get("name")
c) person.name
d) Both person["name"] and person.get("name") are valid.
CORRECT ANSWER: d) Both person["name"] and person.get("name") are valid.
a) 10
b) 20
c) 30
d) 40
CORRECT ANSWER: d) 40 (Negative indexes start from the end, -1 is the last item)
a) Removes the element at index i and returns it.
b) Removes the first element whose value is i.
c) Adds an element at index i.
d) Returns the value at index i without removing it.
CORRECT ANSWER: a) Removes the element at index i and returns it.
CORRECT ANSWER: c) for loop
a) for loop
b) while loop
c) do-while loop (Note: Python doesn't have a native do-while)
d) None of the above
CORRECT ANSWER: d) None of the above (A while loop condition is checked first, so it may not execute at all. for loops depend on the sequence.)
a) [1, 2, 3, 4, 5]
b) [1, 2, 3, 4]
c) [0, 1, 2, 3, 4]
d) [5, 4, 3, 2, 1]
CORRECT ANSWER: b) [1, 2, 3, 4] (The stop value is exclusive)
a) Skip the rest of the code inside a loop for the current iteration only.
b) Exit a loop entirely.
c) Start the next iteration of a loop.
d) Define a function.
CORRECT ANSWER: b) Exit a loop entirely.
a) A
b) B
c) C
d) None
CORRECT ANSWER: b) B
a) A specific number of iterations is reached.
b) The loop counter is less than 10.
c) A condition is true.
d) A user presses a key.
c) Modules
d) Return values
CORRECT ANSWER: b) Parameters
a) A parameter
b) A definition
c) An argument
d) A scope
CORRECT ANSWER: c) An argument
a) Global scope
b) Local scope
c) Public scope
d) Module scope
CORRECT ANSWER: b) Local scope
a) It uses loops to repeat code.
b) A function calls itself.
c) It is the only way to calculate factorials.
d) It cannot return a value.
CORRECT ANSWER: b) A function calls itself.
a) Exits the program.
b) Exits the function and sends a value back to the caller.
c) Prints a value to the console.
d) Restarts the function.
CORRECT ANSWER: b) Exits the function and sends a value back to the caller.
a) Opens a web browser.
b) Opens a file for reading or writing.
c) Opens a new program window.
d) Opens a connection to a database.
CORRECT ANSWER: b) Opens a file for reading or writing.
b) using
c) import
d) require
CORRECT ANSWER: c) import
a) Check if a function exists.
b) Separate code that should be run only when the script is executed directly, not when imported as a module.
c) Define the main variable of a program.
d) Ensure the program runs on the main thread.
CORRECT ANSWER: b) Separate code that should be run only when the script is executed directly, not when imported as a module.
a) To execute code that might cause an exception.
b) To handle an exception.
c) To define a function.
d) To import a module.
CORRECT ANSWER: a) To execute code that might cause an exception.
a) You divide by a float.
b) You try to open a file that doesn't exist.
c) You attempt to divide a number by zero.
d) You use an invalid index for a list.
CORRECT ANSWER: c) You attempt to divide a number by zero.
a) Create complex mathematical formulas.
b) Read and write data in CSV (Comma-Separated Values) format.
c) Manipulate image files.
d) Send emails.
CORRECT ANSWER: b) Read and write data in CSV (Comma-Separated Values) format.