Using the Editor
A guide for students on how to use the code editor.
Interface Overview
The editor has two main areas:
- Code Tab — Where you write your Python code
- Output Tab — Where you see results when you run your code
Writing Code
The Editor
The code editor provides:
- Syntax highlighting — Python keywords, strings, and comments are color-coded
- Line numbers — Helpful for finding errors
- Auto-indent — Press Enter and the cursor indents automatically
- Tab support — Press Tab for 4 spaces of indentation
Starter Code
Some assignments come with starter code already filled in. This might include:
- Function definitions you need to complete
- Comments explaining what to do
- Test code to check your work
TIP
Don't delete the starter code! Complete the # TODO sections.
Running Your Code
Click "Run Code"
- Write your Python code in the editor
- Click the Run Code button (blue)
- The Output tab opens automatically
- See your program's output
Using input()
If your code uses input():
- A text field appears in the output area
- Type your response
- Press Enter to continue
Example:
name = input("What is your name? ")
print(f"Hello, {name}!")When you run this:
- You'll see "What is your name?" in the output
- Type your name in the input field
- Press Enter
- See "Hello, [your name]!"
Understanding Errors
Syntax Errors
If your code has a syntax error (like a missing parenthesis), you'll see:
SyntaxError: unexpected EOF while parsingFix: Check for missing parentheses, quotes, or colons.
Runtime Errors
If your code runs but crashes, you'll see the error type and line number:
NameError: name 'pritn' is not definedFix: Check for typos in variable or function names.
Common Errors
| Error | Cause | Fix |
|---|---|---|
SyntaxError | Missing :, ), or " | Check your punctuation |
NameError | Typo in variable name | Check spelling |
TypeError | Wrong type (e.g., "5" + 5) | Convert types properly |
IndentationError | Wrong indentation | Use consistent spaces |
Submitting Your Code
Before Submitting
- Test your code — Click "Run Code" first
- Check for errors — Fix any red error messages
- Verify output — Make sure it matches what's expected
Click "Submit Code"
- Click the Submit Code button (green)
- Wait for "Submitting..." to complete
- See "Submitted successfully" with a link
View Your Results
Click "View on Gradescope" to see:
- Your submission
- Autograder results
- Your score
Tips for Success
Test Before Submitting
Always run your code locally first. It's faster than waiting for Gradescope.
Read Error Messages
Error messages tell you:
- What went wrong
- Which line has the problem
Start Simple
If your code isn't working:
- Comment out most of your code
- Test one small piece
- Add more code gradually
Use Print Statements
Add print() statements to see what your variables contain:
x = calculate_something()
print(f"x = {x}") # Debug: see what x isKeyboard Shortcuts
| Shortcut | Action |
|---|---|
Tab | Insert 4 spaces |
Shift+Tab | Remove indentation |
Ctrl/Cmd+Z | Undo |
Ctrl/Cmd+Shift+Z | Redo |
Ctrl/Cmd+/ | Comment/uncomment line |
Getting Help
Click the ? button in the bottom bar to see the help modal with quick tips.