Paul's Python CoursePPC

Project 1 of 13, for Paul

Course Sign

A first program: print the sign for the Clocktower's front door.

About 20 minutes, in 13 steps, free and with no account needed.

Start the project

No account needed. Your work is kept in this browser until you sign up.

The brief

  • PaulWelcome to the Workshop! Your first program's going to be the sign for the front door.
  • PaulThe old one fell off in the rain, and people started coming in asking us to fix the clock.
  • PaulIt just needs the name, what we teach, the hours and a little warning at the bottom, nothing fancy.

Write a program that shows the sign for the Clocktower's front door: the course's name, what it teaches, the opening hours and a note for visitors.

Four lines, exactly as below, in this order. You don't need to know any Python yet. The next steps explain each thing you'll use, one at a time.

What it prints
PAUL'S PYTHON COURSE
Python, from the ground floor up
Open Monday to Friday, 9 till 5
Ignore the clock. It says 3:14.

What you learn

The lesson, step by step

  1. What a program is

    A program is a list of instructions for a computer, written in a language it can follow. This course uses Python.

    Each line is one instruction. When you press Run, Python carries out the lines one at a time, starting at the top and working down. Anything the program shows appears in the Output panel.

    The program on the right has three lines, and each one shows a few words. Press Run: the words appear in the same order as the lines.

    People often expect the computer to work out what they meant, or to pick its own order. It never does. It does exactly what each line says, from the top down.

  2. print() shows words

    print() is the instruction that shows something in the Output panel. You write print, then brackets, and inside them the words to show, in quotes. So print("Open at 9") shows:

    Open at 9
    

    The word print, the brackets and the quotes are instructions to Python, so they don't appear. Only the words between the quotes do. That's the usual surprise: people expect the whole line to show.

    Each print() shows one line, and the next one starts underneath. With nothing in the brackets, print() shows an empty line. With commas between several pieces of text, it shows them in a row, with a space between each: print("Closed", "at 5") shows Closed at 5.

  3. What will it print?

    A sign for a door, as a program with two print() lines. You've seen everything it uses: the order the lines run in, and what print() shows.

  4. Text goes in quotes

    A string is Python's word for a piece of text. It goes inside quotes: "Ring the bell".

    The quotes mark where the text starts and ends. Without them, Python would read the words as instructions. The quotes never print: only the text between them does.

    Double quotes "like this" and single quotes 'like this' both work, as long as both ends match. Choose the kind that isn't in your text. Neil's desk has an apostrophe, so line 1 puts double quotes outside. Single quotes would end the string after Neil, and Python would stop with an error: a message saying it couldn't read the line.

    Line 3 shows one more thing: + joins two strings into one.

  5. Which quote ends it?

    The text Riya's sketchbook has an apostrophe in it, and this line puts single quotes around the outside.

  6. Notes for people

    A comment is a note in the code for people to read. It starts with #, and Python skips everything from the # to the end of that line. Nothing in a comment runs or prints.

    Programs usually start with a comment saying what they're for, like line 1 on the right. Then the next person to open the file knows what it is before reading any code. Often that next person is you, a month later.

    A comment can also go at the end of a line, as on line 3. The code before the # still runs.

    Run it: two lines appear, and neither note does. People sometimes expect comments in the output. They never are. Only print() puts words there.

  7. What do the notes do?

    Three lines of code, and two notes for people. Work out which parts Python runs.

  8. Change it and see

    The note above the Workshop chalkboard, as a program. Each task changes one thing, so you can see what that part does. If you get lost, Reset in the ... menu above the code puts it back.

  9. How Paul would do it

    • PaulI did one for Neil's door last week. It's the same job as yours, just a smaller door.

    A program like the one you're about to write: the sign on Neil's door. It uses only what you've just learned: comments, print() and strings.

    The three labels beside the code are the steps Paul took. Your file for the Build starts with the same three steps, as comments. Look closely at line 6: its text has quote marks in it.

  10. Fix Caitlin's version

    • CaitlinI knocked up a sign for the arcade cabinet upstairs, it only took me about two minutes.
    • CaitlinBut it keeps saying unterminated string, and I did terminate it, look, there's a quote right there.

    Caitlin's sign has one mistake. Run it: nothing prints, not even line 1, because Python reads the whole file before it runs any of it, and it can't read line 2.

    The error says the string is unterminated: it starts, but Python never finds the quote that ends it. Fix it so the program prints:

    ARCADE CABINET
    Beat Caitlin's high score
    Two goes each
    
  11. Make the Clocktower sign

    Now the real one: the sign for the Clocktower's front door. Your program prints these four lines, exactly:

    PAUL'S PYTHON COURSE
    Python, from the ground floor up
    Open Monday to Friday, 9 till 5
    Ignore the clock. It says 3:14.
    

    Your file starts with Paul's three steps as comments. Under the first, write a comment of your own saying what the program is for. Then write one print() for each line of the sign, in order. PAUL'S has an apostrophe, so choose its quotes with care.

    The checks look for the first line, then the whole sign in order, then your comment. Capitals, commas, full stops and the apostrophe all count.

  12. Ship it

    • PaulThat's spot on, every line's straight and you even got the apostrophe in the right place.
    • PaulMind you, if I ever fix the clock that last line's going to be wrong, but I can live with that.

Guides that go with it