Preporato

First Day at Bean There: Your First Python Script

–
0 XP
Files
~/labuser
hello.py
print("Hello, world!")

Terminal
Type a command below or click Run...
$
Step 1 of 5 · ~5 min

Run your first script

Step 1: Run your first script

The dark panel at the bottom is a terminal: you type a command, press Enter and it runs. Python runs right here in your browser, so there's nothing to install. It reads a file of instructions and runs them from top to bottom.

hello.py is open in the editor. It has one line:

print("Hello, world!")

print shows whatever is inside its brackets. The quotes mark a string: a piece of text, kept exactly as you write it.

  1. Press Run. The lab runs python3 hello.py for you, and the terminal shows Hello, world!. You can also type python3 hello.py in the terminal yourself and press Enter.
  2. Sam wants the till to greet customers. Change the words between the quotes to Good morning from Bean There! and press Run again.
  3. Press Check.

Break it on purpose. Delete the closing quote and press Run. Python stops and prints a SyntaxError that points at the line it couldn't read. An error is Python telling you where it got confused, and the last line of it names the problem. Put the quote back before you press Check.

Knowledge Check

Predict, then try it. What does this line show?

print("2 + 2")
What “Run checks” will verify

Your work for this step is graded automatically against the lab’s check script. Finish the tasks above, then run the check to advance.

1 / 5