Code rooms
A code room is a page where you and a student type and run Python together, live, outside any group. Each of you has your own cursor, with your name on it. Find your rooms under Code in the top bar.
Making a room and sharing it
Press New code room, give it a name (the student's, or the topic), and it opens. To bring someone in, press Share in the room's bar:
The link, at the top. Press Copy link and send it: you don't need their name or email address. At first it opens for anyone with an account, to type. Choose who it opens for:
- Anyone with an account can type (or can view): they sign in, or make an account, and are in the room. It stays under their Code, Shared with me.
- Anyone with a first name can type: no account needed. They give a first name and are in the room, for a day, while you are in it.
- Only people added: the link opens only for the people you add by name.
New link stops the old link at once, for anyone you sent it to.
Or add people by name, under the link: their sign-in name or email address. Each can type or only look, and they're told by the bell.
Who types (above the code, once you've shared the room) chooses who types now: both of you, only them while you watch, or only you.
Running the code
Run (or Ctrl+Enter) runs the code in your browser. What it prints shows under it, and the
others in the room see your run too, named. When the program asks a question (input()), type
the answer in the output and press Enter.
More than one file
A room can hold up to 10 files, as tabs over the code. Press + at the end of the tabs for a New file: give it a name and choose what it is.
- Python: code that runs. Other files can
importit: a file calledhelpers.pyisimport helpers. Its name is letters, digits and_, with no spaces. - Text: data a program reads, such as a list of names or scores:
open("scores.txt").
Run runs the file you are looking at (it says which: Run main.py). Looking at a text file, it runs the Python file you ran last. If something goes wrong in another file, the error says where, with a button to show that line.
Each of you can be in a different file: a coloured dot on a tab shows who else has it open, and Follow takes you to the file the other person is typing in. The file you are looking at is in the page's address, so a link opens it.
Right-click a tab, or press the ⋯ on the tab you're in, to Rename…, Download or Delete file it. A deleted file can come back with Undo in the note that says so.
Files your program saves
What a program writes stays in the room, as on a computer. A program that adds a line to
scores.txt (open("scores.txt", "a")) changes the room's scores.txt for everyone; a file it
makes appears as a new tab, shown the first time. The next run reads it, so a high-score table
or a list builds up run after run. A line under the output says what was saved; click a file's
name to see it.
- To undo what a program did to a file, open it and choose History… in the room's ⋯.
- A program never changes a file that runs (
main.py, a pseudo-code file), and the room keeps text files only, 10 of them at most. A file's name needs an ending, such asscores.txt. - Stopped while it waits for an answer, a program keeps what it wrote before.
- If you can only look at the room, what your run writes is for that run only.
AQA pseudo-code
For GCSE students taking AQA's Computer Science (8525): choose AQA pseudo-code in New file. Write it as the exam does, and Run shows whether it works: Run turns it into Python, line for line, and runs that. As Python, beside Output, shows the same program in Python.
Type <- and it becomes ← (and !=, <=, >= become ≠ ≤ ≥). Only the words of
AQA's own guide are allowed: print or if in small letters stops the run at that line, and
says what AQA writes instead.
| To… | AQA writes |
|---|---|
| Give a value | total ← 0, CONSTANT MAX ← 10 |
| Read and show | name ← USERINPUT, OUTPUT 'Hello ', name |
| Choose | IF … THEN, ELSE IF … THEN, ELSE, ENDIF |
| Repeat | WHILE … ENDWHILE, REPEAT … UNTIL … |
| Count | FOR i ← 1 TO 10 STEP 2 … ENDFOR, FOR letter IN word … ENDFOR |
| Compare and combine | = ≠ < > ≤ ≥, AND OR NOT |
| Calculate | + - * /, DIV (whole number), MOD (remainder) |
| Subroutines | SUBROUTINE add(a, b) … RETURN a + b … ENDSUBROUTINE |
| Arrays | scores ← [3, 5, 7], scores[0] (from 0), LEN(scores) |
| Records | RECORD Car … make : String … ENDRECORD, Car('Ford') |
| Text | LEN(t), POSITION(t, 'm'), SUBSTRING(2, 9, t) (2 to 9) |
| Change a type | STRING_TO_INT, STRING_TO_REAL, INT_TO_STRING, REAL_TO_STRING |
| Characters and chance | CHAR_TO_CODE('a'), CODE_TO_CHAR(97), RANDOM_INT(1, 6) |
OUTPUT with several values shows them one after another, with nothing between: put the
spaces in the words (OUTPUT 'Total: ', total).
OCR pseudo-code
For GCSE students taking OCR's Computer Science (J277): choose OCR pseudo-code in New
file. It is OCR's Exam Reference Language, as the specification has it: Run turns it into
Python and runs it, and As Python shows that Python. Words OCR doesn't use (len(…), elif,
a colon after if) stop the run at that line, and say what OCR writes instead.
| To… | OCR writes |
|---|---|
| Give a value | total = 0, const vat = 0.2, global userID = "Cust001" |
| Read and show | name = input("Name? "), print("Hello " + name) |
| Choose | if … then, elseif … then, else, endif |
| Choose by value | switch day :, case "Sat":, default:, endswitch |
| Repeat | while … endwhile, do … until … |
| Count | for i = 0 to 9 step 2 … next i |
| Compare and combine | == != < <= > >=, AND OR NOT |
| Calculate | + - * /, ^ (power), DIV (whole number), MOD (remainder) |
| Sub programs | procedure greet(name) … endprocedure, function … return … endfunction |
| Arrays | array names[5], array board[8,8], board[1,0] = "Pawn" |
| Text | name.length, .upper, .lower, .substring(3, 5), .left(4), .right(3) |
| Change a type | str(…), int(…), float(…), real(…), bool("True") |
| Characters, chance | ASC("A"), CHR(97), random(1, 6) |
| Files | newFile("log.txt"), f = open("log.txt"), f.readLine(), f.writeLine("…"), f.endOfFile(), f.close() |
.substring(3, 5) is 5 characters from position 3. What a program writes to a file is kept in
the room, as a Python program's is (see "Files your program saves").
Drawing with turtle
import turtle works in a room, as in Python on a computer. Press Run: once the program
draws, Output and Drawing become tabs, and the turtle draws at its own speed
(speed(0) draws at once). Show at once skips to the end; Draw again watches it again.
Everyone in the room sees the drawing.
- A question asked with
numinput()ortextinput()shows in Output, asinput()does. - If the program goes wrong, Output shows the error, and Drawing what it drew before.
- Keys, clicks and timers work (
onkey,onscreenclick,ondrag,ontimer): the program keeps running after its last line, and the drawing says what to press. Press the keys with the drawing selected (click it first if it isn't), and Stop when you have finished. Rememberscreen.listen(), or keys do nothing. This needs Chrome, Edge or Firefox on a computer. - Shapes of your own and
undo()don't work.
The room's menu
The ⋯ at the right of the room's bar holds everything else, in this order:
- Find in code (or Ctrl+F in the code).
- Share…: the same window as the bar's Share (on a phone, it is only here).
- Download main.py: the file you're looking at, to keep or open in another editor. With more than one file, Download all (.zip) keeps them all in one.
- Make a copy: a new room of your own with the same files, shared with nobody. Handy for giving the next student the same start.
- Open files…: files from your computer, each as a new tab, for everyone in the room.
- Bigger text and Smaller text: for sharing your screen, or a small laptop. Remembered on this computer for every room.
- Wrap long lines: long lines go on to the next line (ticked), or run on to the right.
- Replay…: the file you're looking at being written, change by change, like a video. Play it, pause it, or drag to any moment. Handy for seeing where a student stopped to think.
- History…: earlier versions of the file, one every few minutes of typing and one before most of it was replaced. Choose one to see it, or Compare with now. Bring back this version puts it back for everyone; Ctrl+Z takes it back again.
- Clear the code…: empties the file you're looking at. It asks first, and Ctrl+Z brings it back.
- Rename… and Delete room (yours), or Leave room (one shared with you).
Finding your rooms
The Code page lists your rooms. On the left, Recent has those changed in the last two weeks, and Starred those you starred: point at a room's card and click its ☆, or choose Star in its ⋯ menu. My folders sorts your rooms your way: the + beside it makes a folder, and Move to folder… in a room's menu puts it there. Rooms other tutors share with you are under Shared with me.
Deleting and the Bin
Delete room takes the room away for everyone, and puts it in the Bin at the foot of the Code page. The note that says so has Undo. In the Bin, Put back brings it back as it was, shared with the same people. A room is deleted for good 30 days after it went to the Bin, or at once with Delete for good… there.
Rooms in use (beside Your rooms) says how many rooms you keep and how many your plan has. Rooms in the Bin don't count.