๐Ÿ‘€ This is a preview of what a real lesson looks like โ€” the code editor below is fully working, so give it a try. Real lessons also have a live video call with your teacher, right on this same page. Ready to enroll? โ†’

๐Ÿ—ฃ๏ธ Foundations ยท Week 1

๐Ÿ—ฃ๏ธ The Magic Words

You'll be able to make the computer ask questions, remember the answers, and print them back in a funny story.

๐ŸŽฅ

Your live video call appears here

During a real lesson, you and your teacher are on a live video call right on this page โ€” no separate app to open.

What you'll learn

  • The print() command: making the computer talk.
  • Strings: words in code need quote marks "like this".
  • Variables: labeled boxes where we store information.
  • The input() command: asking the user a question and storing their answer.
  • Concatenation (or f-strings): gluing variables and strings together.

Key vocab

print()stringvariableinput()f-string

Before you run it

Don't run it yet! Read the two lines of code. If you type Sam when it asks your name, exactly what will appear on the screen? Write your guess down first โ€” getting it wrong is the interesting bit.

Try it out

Load the starter code and press Run. Did it do what you expected? Where it didn't, that's the interesting bit.

Take a closer look

  1. Which line makes the computer stop and wait for you to type? How can you tell?
  2. After line 1 has run, what is inside the box called name โ€” the question, or your answer?
  3. Try print("name") and then print(name). Why are they different?
  4. What is the + doing on line 2? What is it gluing together?
  5. What do you think breaks if you swap line 1 and line 2? Predict first, then try it.

Now make it yours

  1. Change the greeting so it says goodbye instead of hello.
  2. Add a second question that asks for a favourite colour, then use that answer in a new print().
  3. Break it on purpose: delete the quote marks around "Hello, " and run it. Read the error out loud, then put them back.

๐Ÿ› ๏ธ Workshop: Interactive Mad Libs

Build a program that asks the user for a series of words, and then outputs a funny, customized story.

  1. Write input() statements asking for a noun, an adjective, a verb, a place, etc.
  2. Save each answer into its own variable (e.g. user_noun = input(...)).
  3. Write a multi-line story using print() that weaves those variables into the text.

Bonus: Trade stories with a partner and see whose Mad Lib gets the biggest laugh.

Think about it

What was trickier: getting the input() right, or making the story actually funny?

Want to go further?

๐Ÿ“– Look it up

๐ŸŽฎ Practice

  • futurecoder โ†—

    Free, runs in your browser, starts from zero. It gives hints instead of just the answer.

  • Python Tutor โ†—

    Paste your code and step through it one line at a time. The best way to SEE what a variable is holding.

๐Ÿš€ Go deeper

Console

Press Run to see what happens.