Python quiz
37 questions from the Python track. Score 80% or higher to unlock a certificate.
Why Python for Agents
1. How does output appear in the Python boxes on this site?
Variables and Names
2. Which name follows usual Python style for a variable?
Types: Numbers, Text, True/False, and None
3. What is bool("False") in Python?
Compare and Combine Values
4. You have a = [1, 2] and b = [1, 2]. What is true?
Strings (Text)
5. What does "abcdef"[1:4] return?
Numbers and Math
6. What is the value of 7 // 2 in Python 3?
True, False, and None
7. Why can if result lie when result is 0?
Lists
8. What does memory.append("act") give you back?
Index and Slice
9. What does "abcd"[1:3] give you?
Tuples and Sets
10. How do you write an empty set?
Dictionaries
11. What does action.get("thought", "") give you if thought is missing?
Nested Data (Traces)
12. How do you read a nested field without crashing if a key is missing?
If, Elif, and Else
13. What does handle_query("") return if empty text is treated as false?
Match and Case
14. What does case _ mean in a match?
Loops and Budgets
15. Which loop fits "run until the goal is true or steps hit 8"?
Functions
16. What does return do that print does not?
Scope, Defaults, and Extra Arguments
17. Why is def add_event(event, history=[]) dangerous?
Unpacking
18. After first, *rest = ["think", "act", "observe"], what is rest?
Modules
19. When is a module’s __name__ equal to "__main__"?
JSON and Text
20. Which call turns a Python dict into a JSON string?
with, Files, and Paths
21. Why use with when you open a file?
Errors and try/except
22. What is wrong with writing except: with no error type?
Copy vs Change in Place
23. Two agents share one transcript list. Agent A appends a message. What happens?
Comprehensions
24. When is a for-loop clearer than a comprehension?
Classes
25. When is a function enough, with no class?
Dataclasses
26. What does frozen=True do on a dataclass?
Type Hints
27. Do type hints stop a wrong JSON value when the program runs?
Useful Standard Library
28. Why is a long time.sleep a problem in an agent loop?
Regular Expressions
29. You have a full, clean JSON string from the model. What should you try first?
Logging and Secrets
30. How should an API key appear in a log?
Virtual Envs and pip
31. What is a virtual env?
HTTP and APIs
32. What does status 429 mean?
Parse JSON from a Model
33. Why should you never eval() text from a model?
Retries and Timeouts
34. Which result should you retry?
Async in Simple Words
35. In this lesson, concurrent means…
Tests
36. Why write tests for tools, parse_action, and goal_satisfied?
A Mini Agent in Python
37. What should the loop do when it hits max_steps?