Guide Python Beginner

Variables and Memory: Chapter Practice

Apply variables and memory with a mini lab and knowledge check.

1 min read

Mini lab

Copy a list before appending a server name. Show that the original is unchanged.

Expected output: [‘web-01’] and then [‘web-01’, ‘db-01’]

HintUse the chapter examples to choose the operation, then run your version before opening the solution.
Show solution
original = ["web-01"]
copy = original.copy()
copy.append("db-01")
print(original)
print(copy)

Knowledge check

Does a shallow copy copy nested lists too?

Check your answerNo. Nested mutable values are still shared.

Finish the chapter

  • Explain each operation without reading the lesson.
  • Change the sample input and predict the output before running it.
  • Revisit the chapter if the result differs from your prediction.

Back to this chapter · Choose the next chapter

Add More Questions to This Guide

Know a question that should be here? Share it and help the community!

Open Google Form