CodeBlanks Logo Icon CodeBlanks

Data model

Set up the data model and collections.

Data model: add a new grade

In this lesson you will add a new grade to the grades list with append. append puts an item at the end of the list and grows it:

grades.append(95)
print(len(grades))  # 4

The starting code includes the previous lesson's solution — grades = [85, 90, 78] and print(grades) are ready. You will add the append call and new output.

This shows the list growing dynamically.

Practice Add a new grade and print the count

Write grades.append(95). Then write print("eklendi:", len(grades)).

Starter code

main.py
# Grade calculator - grades list
grades = [85, 90, 78]
print(grades)
# add a new grade and print the count

Sample solution

main.py
grades = [85, 90, 78]
print(grades)
grades.append(95)
print("eklendi:", len(grades))

Expected output

[85, 90, 78]
eklendi: 4

Next step: business logic

The data model is ready — you can now dynamically add grades to the list. In the next lesson you will add a business logic layer: computing the average with sum and len.

This layer will turn raw data into a meaningful result. The average is a fundamental statistic that summarises the grades. The starting code carries the previous solution; you only add the calculation.

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Match the data model

Term Meaning
append Adds to end
len(grades) Item count
[85, 90, 78] Three-grade list
95 New grade

2 What does grades.append(95) do?

  • Puts 95 at the start
  • Removes 95
  • Adds 95 at the end Correct answer
  • Empties the list

Explanation: append always adds the item at the end of the list.

3 Complete the append call

Question
grades.____(95)
Answer
grades.append(95)

Explanation: grades.append(95) adds 95 to the list.

All lessons in Beginner