1. What does int(3.9) return?
- 4
- 3
- 3.9
- ValueError
Show answer
Answer: 3
int() truncates toward zero; use round() to round.
Lesson: Data Types
15 questions from the Python Fundamentals: From Basics to Async course, each with the correct answer and an explanation. Try to answer before you open the answer.
Answer: 3
int() truncates toward zero; use round() to round.
Lesson: Data Types
Answer: tuple
A tuple can't be changed after creation.
Lesson: Data Types
Answer: Only if the loop finished without `break`
A `break` skips the loop's `else`.
Lesson: Loops
Answer: [0, 2, 4]
Only even numbers from 0-4 pass the `if` filter.
Lesson: Comprehensions & Nested Data
Answer: @classmethod
@classmethod receives the class itself (cls) and can build and return a new instance.
Lesson: Class & Static Methods
Answer: __init__, __repr__ and __eq__
Dataclasses generate these from the annotated fields.
Lesson: Dataclasses & Enums
Answer: It produces items lazily instead of storing them all in memory
Generators compute one value at a time on demand, so huge or infinite sequences don't need to fit in memory.
Lesson: Generators & yield
Answer: tuple
Tuples cannot be changed after creation.
Lesson: Async Basics
Answer: [0, 1, 4, 9]
range(4) yields 0..3 and each is squared.
Lesson: Async Basics
Answer: The list is created once and shared across calls
Mutable defaults persist between calls; use None or a factory.
Lesson: Async Basics
Answer: The file is closed even if an error occurs
Context managers run cleanup automatically.
Lesson: Async Basics
Answer: Produces a value lazily and pauses the function
Generators resume where they paused on the next call.
Lesson: Async Basics
Answer: @classmethod
A classmethod receives cls and can return a new instance.
Lesson: Async Basics
Answer: async def
`async def` defines a coroutine you can await.
Lesson: Async Basics
Answer: venv
A virtual environment keeps dependencies per project.
Lesson: Async Basics