Skip to Content
Python for Beginners: Write Code That Actually Runs, Then Make It Better
Beginner
0 likes
Courses
Python for Beginners: Write Code That Actually Runs, Then Make It Better

Check Yourself: Organizing Your Code

Five questions on functions, lists and dictionaries. A quick check before you move on to errors.

Course content

Sign in to save your progress.

Course Home
1. Your function calculates a total and prints it, but result = calculate_total(...) gives None. Why?
2. The same discount rule is pasted in five places, and the minimum changed. What is the long-term fix?
3. You need to look up a product's price by its name, quickly and often. Which structure fits?
4. product["weight"] crashes with KeyError because some products have no weight. What is a safe way to read it?
5. fruits = ["apple", "banana", "mango"]. What does fruits[1] return?

About

Five questions on functions, lists and dictionaries. A quick check before you move on to errors.

Duration
5 min
Last update
09/06/2026
Was this helpful?
​ 0 ​ 0

Comments (0)

Sign in to comment

No comments yet.