Python Programming Fundamentals

By Devin Park · Updated May 25, 2026

Questions30
Passing Score70%
Format63% Multiple Choice
Sessions Logged2,078
Your progressLog in / Register to track times taken, best score, questions mastered, and coverage on this quiz.
Rating
Community rating 4.6 out of 5 from 11 ratings.
4.6 (11)

Topics covered

This quiz

Uncategorized30 (100%)

Uncategorized30 questions

Question catalog for this preview

Catalog listing of the 5 preview questions for this quiz.

Question 1

In Python, a class that cannot have instances (objects) created directly and is meant only to be subclassed is called an [[blank1]] class. It is created using the `[[blank2]] ` module, inheriting from `ABC`, and marking methods with the `@[[blank3]]` decorator.

*End of Quiz — Python Programming Fundamentals*

Question 2

Place the following steps in the correct order to read a file and print its contents in Python:

Answer choices

  • A. Close the file with `file.close()` (or use a `with` block to close automatically)

  • B. Open the file using `open("filename.txt", "r")`

  • C. Read the content using `file.read()` or loop with `for line in file`

  • D. Print or process the content

Question 3

What is the purpose of `try` / `except` blocks in Python?

Answer choices

  • A. To test whether a variable's value is True

  • B. To handle exceptions (errors) gracefully without crashing the program

  • C. To loop through items in a list

  • D. To define conditional logic (if/else alternative)

Question 4

A Python function is defined using the [[blank1]] keyword, followed by the function name and parentheses. The function returns a value using the [[blank2]] keyword. If no return statement is present, the function returns [[blank3]] by default.

Question 5

Which of the following are valid ways to iterate over a dictionary `d = {"a": 1, "b": 2}` in Python? (Select ALL that apply)

Answer choices

  • A. `for key in d:` — iterates over keys

  • B. `for key in d.keys():` — iterates over keys

  • C. `for value in d.values():` — iterates over values

  • D. `for key, value in d.items():` — iterates over key-value pairs

  • E. `for i in range(len(d)):` — iterates by index (standard approach)