Welcome to CS Room

First day on CS Room: use the terminal, run Python, and publish a live web page

CS Room originalPython1 class periodNot autograded

README.md

Welcome to CS Room

In this lesson you'll use the terminal, write a Python program, save data to a file, and put a web page on the internet at an address anyone can open.

Work through the five parts in order. Each part starts by opening a terminal in the right folder, so you can pick up where you left off on another day.

Part 1: Find your way around

CS Room has three panels:

  • The file list (left): your folders and files. Click a file to open it, right-click for more options.
  • The editor (middle): where you read and write code. Changes save on their own.
  • The terminal (bottom): where you type commands and run programs.

Right-click this lesson's folder in the file list and choose Open in terminal. Then type this in the terminal and press Enter:

pwd

pwd means "print working directory". It shows the folder the terminal is in.

Part 2: Terminal basics

CommandWhat it does
pwdShow the folder you're in
lsList what's in it
cd part3Go into the part3 folder
cd ..Go up one folder
mkdir notesMake a folder called notes
touch idea.txtMake an empty file called idea.txt
cat idea.txtPrint a file
rm idea.txtDelete a file
rm -r notesDelete a folder and everything in it

Three keys save a lot of typing:

  • Tab finishes a file or folder name for you. Type cd pa and press Tab.
  • Up arrow brings back your last command.
  • Ctrl+C stops a running program. It doesn't copy in the terminal; to copy, select the text and press Ctrl+Shift+C (or Cmd+C on a Mac).

Try them out:

mkdir practice
cd practice
touch song.txt movie.txt
ls
cd ..
rm -r practice

Watch the file list on the left as you go. The terminal and the file list show the same files.

Part 3: Your first program

Right-click the part3 folder and choose Open in terminal. Open part3/hello.py. It's one line:

print("Hello, world!")

Run it:

python hello.py

Now change the file so it asks for your name:

name = input("What's your name? ")
print(f"Hello, {name}!")

Run it again with python hello.py (press the up arrow to get the command back). The green Run button above the editor also runs the file you have open.

If you have time: change hello.py so it asks for a number and prints its times table:

What number? 7
7 x 1 = 7
7 x 2 = 14
...
7 x 10 = 70

You'll need int(input(...)) to turn what the user types into a number, and a for i in range(1, 11): loop.

Part 4: Save to a file

Programs remember things between runs by writing files.

Right-click the part4 folder and choose Open in terminal. (From the terminal, cd ../part4 does the same thing if you're still in part3: .. means "the folder above".) Then:

python journal.py

Type write and then a journal entry. Run ls and you'll see a new file, journal.txt. Print it with cat journal.txt.

If you have time: run python journal.py again and type read. Nothing happens, because read_journal() isn't written yet. Open journal.py, find the TODO, and finish it. Test it by writing a few entries and reading them back.

Part 5: Put a page on the internet

Right-click the part5 folder and choose Open in terminal. Then:

pip install -r requirements.txt
python app.py

The first command installs Flask, the library that runs the web server. When the server starts, a message pops up saying the port is live, with a web address and an Open button. Click Open to see your page.

If you miss the message, click Ports next to the terminal tabs to find the address again.

That address works on any device. Send it to a classmate.

Leave the server running and open app.py. Change the text inside <h1>...</h1>, then refresh the page in your browser. The server restarts on its own when the file changes.

Press Ctrl+C in the terminal to stop the server. The address stops working until you start it again.

For teachers

Welcome to CS Room

A first-day lesson. Students learn the terminal, run and change a Python program, save data to a file, and end by publishing a web page at an address anyone can open. The student README walks them through every step, so most of class is students working while you circulate.

Time: 1 class period of 45–50 minutes. Two exercises in the README, the times table and the journal reader, are marked “If you have time”. They're for fast finishers or a second day. Prerequisites: none

Goals

By the end, students can:

  • move around with pwd, ls and cd, and make and delete files from the terminal
  • run a Python program from the terminal and change it
  • explain that a program saves data between runs by writing a file
  • start a web server and share its address

Before class

  • Import the lesson into your class from the Lessons page, or with New assignment → Use a lesson on the class's Assignments tab. It arrives as a draft.
  • Publish it when you're ready. Each student gets their own copy in their class folder.
  • Open it once yourself and run Part 5, so you've seen the "port is live" message students will get.

In class

  1. Show the three panels on the projector: the file list, the editor and the terminal. Right-click the lesson folder, choose Open in terminal, and run pwd. (5 min)
  2. Students work through Parts 1 and 2. (10 min)
  3. Part 3: students run hello.py and change it to ask for their name. (8 min)
  4. Part 4: students write a journal entry and find journal.txt with ls and cat. (5 min)
  5. Part 5: students start the server, open their page and change its heading. (10 min)
  6. Students paste their addresses into a shared doc and open two classmates' pages. (5 min)
  7. Exit ticket: one command and what it does. (2 min)

Students who finish early do the two “If you have time” exercises. If most of the class finishes, give them to everyone on the next day.

Where students get stuck

SymptomNudge
No such file or directoryThey're in the wrong folder. pwd, then cd to the right one.
Typing pwd in the editorThe terminal is the bottom panel.
Times table: "7" * 2 prints 77They forgot int() around input().
ModuleNotFoundError: No module named 'flask'Run pip install -r requirements.txt in part5.
Lost the addressPorts, next to the terminal tabs, lists it.
Page doesn't changeThe server stopped. Check the terminal for an error, then run python app.py again.

Check for understanding

  • Each student's Part 5 address opens and shows their own text, not the starter heading.
  • Ask a student to explain what each command does: pwd, cd .., cat.
  • Ask: what's the difference between the editor and the terminal?
  • Ask: someone opens your address. What happens between their browser and your home() function?

Going further

  • Add a "delete entry" option to the journal.
  • Add a second page to the server, such as /about.
  • Fast finishers can do the Shell Scavenger Hunt lesson next.

Standards

CSTA standards

2017 standards

  • 3A-AP-13Create prototypes that use algorithms to solve computational problems by leveraging prior student knowledge and personal interests.
  • 3A-AP-16Design and iteratively develop computational artifacts for practical intent, personal expression, or to address a societal need while evaluating intended and unintended consequences.
  • 3A-CS-02Compare levels of abstraction, analogy, and paradigm for the interactions between application software, system software, and hardware.
  • 3A-CS-03Develop guidelines that convey systematic troubleshooting strategies that others can use to identify and fix errors.

2026 standards

  • HS-SYS-HW-29Differentiate an operating system as a special type of software that manages both the hardware and other software components of a computing system, including handling memory and peripherals.
  • HS-PRO-PD-13Use documentation, libraries, application programming interfaces (APIs), and other tools in program development.
  • HS-ALG-PS-01Design an algorithm using appropriate data structures to solve a problem or express an idea.
  • HS-PRO-TR-19Evaluate a computing technology's alignment with design specifications and responsible design values, including its correctness, effectiveness, and user experience.
  • HS-PRO-TR-20Refine a computing technology based on user feedback, testing results, and responsible design values to improve its effectiveness and impact.