Skip to content

Getting Started with Python

This notebook helps you practice running code and making small changes.

Run in Binder Open in Colab Download notebook

Read here. Practice in a notebook.

This page shows the original notebook. Open Binder or Colab to run and edit cells. Work one cell at a time: some examples are deliberately broken for debugging practice. Download your work before leaving Binder; its sessions are temporary.

View original source

Welcome

This is a practice notebook.

You do not need any prior experience. The goal is to click run, observe output, and make small changes.

How to Use This Notebook

  • Run cells from top to bottom.
  • Read code comments.
  • Change only where told.
  • If something breaks, that is okay.
# Click Run to see output below this cell.
print("Hello, world!")

Nice work - you just ran your first Python code.

# This line stores a name.
name = "Kofi"

# This line shows the result.
print("Hello,", name)
# TODO: Replace "Student" with your own name
name = "Student"

# Run the cell again after changing the value
print("Welcome to Python,", name)
# Check your work
if name != "Student":
    print("Great job — you changed the value successfully.")
else:
    print("Try changing the name and running the cell again.")
# Type a short answer and press Enter.
favorite_color = input("What is your favorite color? ") # When Python uses input(), it pauses and waits for you to type a response.
print("Your favorite color is", favorite_color)
# This code has a small mistake. Fix it and run it again.
print("Python is fun!)

Check Your Work

If things are working, you should have seen output similar to:

  • Hello, world!
  • Hello, Kofi or your name
  • Welcome to Python, followed by your name
  • Your favorite color is followed by your answer
  • Python is fun! after you fix the small mistake

Reflection (write your answers as comments below)

  • What was the easiest part of this notebook?
  • What is one thing you learned about running Python code?

Answer (here)

You Are Ready

Nice job finishing this notebook. You are ready for the next notebook, and making mistakes is part of learning Python.