Learn
68 |Python by writing code and visualizing execution
69 | 70 |This free educational application allows teachers and students to 71 | write Python scripts directly in the web browser, execute those scripts, 72 | single-step forwards and backwards through execution, and view 73 | the run-time state of all data structures.
74 | 75 |Rather than displaying a bland text-based console, the Online Python 76 | Tutor provides a rich visualization of variables, heap objects, and 77 | stack frames. For example, the following code:
78 | 79 |80 | x = ["Alice", "Bob", "Charlie"] 81 | y = x 82 | z = ["Alice", "Bob", "Charlie"] 83 |84 | 85 |
will be visualized as the following HTML diagram, which properly shows 86 | aliasing relationships:
87 | 88 |
Go play with the Online Python Tutor!
92 |Solve
99 |programming problems by writing Python code
100 | 101 |The Online Python Tutor also allows students to practice solving 102 | programming problems like those they would receive for class assignments 103 | or technical job interviews.
104 | 105 |It provides web-based interfaces for writing solution and test code, 106 | executing on a series of graded test inputs, and showing what tests 107 | passed and failed.
108 | 109 |
The above screenshot shows passed and failed tests. The user can 114 | click on the "Debug me" button besides one of the sad faces to debug why 115 | the program failed on a particular test.
116 | 117 |Here are some sample practice problems:
118 | 119 |-
120 |
121 |
- Two-sum 122 |
- Reverse list 123 |
- Remove duplicate characters 124 | 125 |
Debug
132 |existing programs that almost work properly
133 | 134 |Using the Online Python Tutor's bidirectional single-stepping and 135 | data structure visualization capabilities, students can practice 136 | debugging, an important skill which is rarely covered in web-based 137 | programming problems.
138 | 139 |They can work on problems like, "Change at most 2 lines of code to 140 | make this almost-correct Python program work properly." Here are 141 | some sample debugging problems:
142 | 143 |-
144 |
145 |
- In-place reverse 146 |
- Binary search 147 |
- Mergesort 148 | 149 |
Optimize
156 |existing programs to run using fewer instructions
157 | 158 |Students can practice refactoring already-correct programs to run 159 | faster and execute fewer instructions.
160 | 161 |They can work on problems like, "Optimize this program so that it 162 | terminates correctly after running less than 50 lines of Python 163 | code." Here are some sample optimization problems:
164 | 165 |-
166 |
167 |
- Greatest sum 168 |
- Find duplicates 169 |
- List search 170 | 171 |
Create
178 |new practice problems in plain text format
179 | 180 |Teachers can easily create new practice problems by writing them in a 181 | lightweight plain text format. For example, reverse.txt provides the specification 183 | for the Reverse list problem.
184 | 185 |The problem specification format allows constraints like "code 186 | diffs must be less than N lines" (used for debugging problems) and 187 | "tests must terminate in at most M executed Python lines" (used 188 | for optimization problems).
189 | 190 |I plan to add support for semantic constraints like "don't allow 191 | the program to create any auxiliary data structures", which could be 192 | used for problems like "merge these two lists in-place without 193 | creating any new temporary lists".
194 | 195 |