Your first Python program
- 1Your first line, Learn
- 2One line or two, Try
- 3Make it say your name, Try
- 4Your first error, Try
- 5Put the quotes back, Try
- 6The parts of a line, Learn
- 7Commas and notes, Learn
- 8What the comma does, Try
- 9Say hello, Practice
- 10Three lines, Practice
- 11The game will not start, Break/fix
- 12A game's title screen, Your turn
Learn
Your first line
print() shows what you put inside its brackets. Text goes inside quote marks, so Python knows it is text. Each print() shows one line. Press Run.
TryPredict the output
One line or two
What will this print?
print("Hi")
print("there")
TryChange it
Make it say your name
Make it say your name. Text goes inside quotes. Replace ??? with your name, keep the quotes.
Constraint
- Keep print( ), and keep your text inside the quotes.
- Replace ??? with your name.
print("Hello, ???")
Try
Your first error
Take the quotes off and run it. Python can't find anything called Hello, so it stops and tells you.
- Goal: get a NameError
print("Hello")
TryFix the bug
Put the quotes back
Here is your line from before, with no quotes. Put them back.
Constraint
- Put a quote mark on each side of Hello.
print(Hello)
Learn
The parts of a line
printa function, does a job( )holds what to print"Hello"a string, text
print("Hello")
Learn
Commas and notes
A comma prints two things with a space between. A line starting with # is a note Python skips, so it never shows up.
# this line is a note
print("Score", 10)
Look it upNameErrorPython cheatsheet
TryPredict the output
What the comma does
What will this print?
# a note for people
print("Level", 1)
Practice
Say hello
Make the program print exactly this one line:
Hello, Python!
Capital letters, comma and exclamation mark all count.
# Change the text inside the quotes
print("Hello")
Practice
Three lines
Print three lines, in this order, using three print() calls: Ready, then Set, then Go!
Constraint
- Use three print() calls, one for each line.
print("Ready")
Break/fixFix the bug
The game will not start
This program should print two lines, but Python refuses to run any of it. Run it, read the error, then fix it.
print("Welcome to the game!)
print("Press start")
Your turn
A game's title screen
Write a program that prints this title screen, line for line. On the middle line, give print() the text and the numbers as separate values with commas, not as one string.
SPACE DRIFT
Level 1 of 12
Press startConstraint
- On the middle line, give print() 1 and 12 as numbers, with commas between the values.
On your own. Hints open after your first check.
Passed
You can now
print("Hello")