PageSourceSearch

https://reeborg.ca/docs/en/

html reeborg.ca collected 2026-09-25 14:23:00 UTC 16,076 bytes, 303 lines download raw bytes

1<!DOCTYPE html>
2
3
4<html>
5  <head>
6    <meta charset="utf-8">
7    
8    <title>Learn Python with Reeborg! &mdash; Learn Python with Reeborg</title>
9    
10    <link rel="stylesheet" href="_static/reeborg.css" type="text/css" />
11    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
12    
13    
13<script type="text/javascript">
14      var DOCUMENTATION_OPTIONS = {
15        URL_ROOT:    './',
16        VERSION:     '1.0',
17        COLLAPSE_INDEX: false,
18        FILE_SUFFIX: '.html',
19        HAS_SOURCE:  true
20      };
21    </script>
21
22    
22<script type="text/javascript" src="_static/jquery.js"></script>
22
23    
23<script type="text/javascript" src="_static/underscore.js"></script>
23
24    
24<script type="text/javascript" src="_static/doctools.js"></script>
24
25    
25<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
25
26    <link rel="shortcut icon" href="_static/favicon.ico"/>
27    <link rel="index" title="Index" href="genindex.html" />
28    <link rel="search" title="Search" href="search.html" />
29    <link rel="top" title="Learn Python with Reeborg" href="#" />
30    <link rel="next" title="Basic Tutorial" href="basics/index.html" /> 
31
32  
32<script>
33    // intelligent scrolling of the sidebar content
34    // copied from the sphinx website
35    $(window).scroll(function() {
36    var sb = $('.sphinxsidebarwrapper');
37    var win = $(window);
38    var sbh = sb.height();
39    var offset = $('.sphinxsidebar').position()['top'];
40    var wintop = win.scrollTop();
41    var winbot = wintop + win.innerHeight();
42    var curtop = sb.position()['top'];
43    var curbot = curtop + sbh;
44    // does sidebar fit in window?
45    if (sbh < win.innerHeight()) {
46          // yes: easy case -- always keep at the top
47          sb.css('top', $u.min([$u.max([0, wintop - offset - 10]),
48                                $(document).height() - sbh - 200]));
49        } else {
50          // no: only scroll if top/bottom edge of sidebar is at
51          // top/bottom edge of window
52          if (curtop > wintop && curbot > winbot) {
53              sb.css('top', $u.max([wintop - offset - 10, 0]));
54          } else if (curtop < wintop && curbot < winbot) {
55              sb.css('top', $u.min([winbot - sbh - offset - 20,
56                            $(document).height() - sbh - 200]));
57          }
58        }
59    });
60    </script>
60
61
62  </head>
63  <body>
64    <div class="related">
65      <h3>Navigation</h3>
66      <ul>
67        <li class="right" style="margin-right: 10px">
68             <a href="genindex.html" title="General Index"
69             accesskey="I">index</a></li>
70        <li class="right" >
71             <a href="basics/index.html" title="Basic Tutorial"
72             accesskey="N">next</a> |</li>
73        <li><a class="logo" href="/index_en.html" class="fake_button">
74              <img class="logo"  src="_static/robot_e.png" alt="Logo"/>
75              <span class="logo">Reeborg's World</span>
76            </a></li>
77        <li><a href="#">Learn Python with Reeborg</a></li> 
78      </ul>
79    </div>
80  
81      <div class="sphinxsidebar">
82        <div class="sphinxsidebarwrapper">
83  <h3><a href="#">Table of Contents</a></h3>
84  <ul>
85<li><a class="reference internal" href="#">Learn Python with Reeborg!</a><ul>
86<li><a class="reference internal" href="#you-want-to-learn-computer-programming">You want to learn computer programming?</a></li>
87</ul>
88</li>
89</ul>
90
91  <h4>Next topic</h4>
92  <p class="topless"><a href="basics/index.html"
93                        title="next chapter">
93Basic Tutorial</a></p>
94  <div role="note" aria-label="source link">
95    <h3>This Page</h3>
96    <ul class="this-page-menu">
97      <li><a href="_sources/index.rst.txt"
98            rel="nofollow">Show Source</a></li>
99    </ul>
100   </div>
101<div id="searchbox" style="display: none">
102  <h3>Quick search</h3>
103    <form class="search" action="search.html" method="get">
104      <input type="text" name="q" />
105      <input type="submit" value="Go" />
106      <input type="hidden" name="check_keywords" value="yes" />
107      <input type="hidden" name="area" value="default" />
108    </form>
109</div>
110<script type="text/javascript">$('#searchbox').show(0);</script>
110
111        </div>
112      </div>
113
114
115    <div class="document">
116      <div class="documentwrapper">
117        <div class="bodywrapper">
118          <div class="body">
119            
120  <div class="section" id="learn-python-with-reeborg">
121<h1>Learn Python with Reeborg!<a class="headerlink" href="#learn-python-with-reeborg" title="Permalink to this headline">¶</a></h1>
122<p>Learning Python is easy with Reeborg.  All you have to do is read the tutorial
123and try all the examples in <a class="reference external" href="https://reeborg.ca/reeborg.html?lang=en&amp;mode=python">Reeborg’s world</a>.
124I suggest that you keep the tutorial and Reeborg’s World both open but
125in separate windows or tabs.</p>
126<p>Before you actually start the tutorial, have Reeborg take its first step
127by running a program in <a class="reference external" href="https://reeborg.ca/reeborg.html?lang=en&amp;mode=python">Reeborg’s world</a>.</p>
128<p>Hints are clickable and designed to provide useful pointers if you are
129not sure how to proceed.</p>
130<div class="admonition hint">
131<p class="first admonition-title">Hint</p>
132<p class="last">Go to <a class="reference external" href="https://reeborg.ca/reeborg.html?lang=en&amp;mode=python">Reeborg’s world</a>, click on the “run” button
133(small white triangle on blue background)
134and watch Reeborg takes its first step.
135You can also <a class="reference external" href="https://youtu.be/yTdw97KNgGM">view this short video</a>
136to see what it looked like … in a slightly older version.
137You may want to watch it in full screen with HD quality selected.</p>
138</div>
139<div class="section" id="you-want-to-learn-computer-programming">
140<h2>You want to learn computer programming?<a class="headerlink" href="#you-want-to-learn-computer-programming" title="Permalink to this headline">¶</a></h2>
141<div class="figure align-right" id="id3" style="width: 40%">
142<img alt="_images/student.jpg" src="_images/student.jpg" />
143<p class="caption"><span class="caption-text">Student using Reeborg’s World in California, USA.</span></p>
144<div class="legend">
145<em>Photo courtesy of A. Castano.</em></div>
146</div>
147<p><strong>Reeborg’s World has been designed for you!</strong></p>
148<p>The idea I had in mind when I created Reeborg’s World was to create
149a friendly place to learn programming concepts.
150While it is possible to use Javascript, the “normal” language of the web,
151as a programming language to make Reeborg work,
152I’ve decided to focus on Python which is a more
153versatile language and one that is easier to use by beginners and
154advanced programmers alike.</p>
155<p>This tutorial was first written for you and help you learn computer programming.
156However, I have also included
157some information for teachers as well as other users of Reeborg’s World.
158You can ignore such additional information without worrying that you are
159missing something important as you are learning programming concepts.</p>
160<p>This document has been divided into nine major parts.</p>
161<div class="toctree-wrapper compound">
162<ul>
163<li class="toctree-l1"><a class="reference internal" href="basics/index.html">A. Basic tutorial</a></li>
164<li class="toctree-l1"><a class="reference internal" href="recursion/index.html">B. Recursion</a></li>
165<li class="toctree-l1"><a class="reference internal" href="variables/index.html">C. Variables</a></li>
166<li class="toctree-l1"><a class="reference internal" href="oop/index.html">D. Object Oriented Programming</a></li>
167<li class="toctree-l1"><a class="reference internal" href="functional/index.html">E. Higher-Order Functions</a></li>
168<li class="toctree-l1"><a class="reference internal" href="exercises/index.html">F. Programming Exercises</a></li>
169<li class="toctree-l1"><a class="reference internal" href="reference/index.html">G. Reeborg's World Reference</a></li>
170<li class="toctree-l1"><a class="reference internal" href="python/index.html">H. Python: a brief overview</a></li>
171<li class="toctree-l1"><a class="reference internal" href="contribute/index.html">I. Contribute!</a></li>
172</ul>
173</div>
174<p>If you click on any of the above part title, you will be taken to a
175page with a more detailed table of contents for that part.</p>
176<div class="admonition-for-educators admonition">
177<p class="first admonition-title">For educators</p>
178<div class="figure" id="id4">
179<img alt="_images/rurple_book.png" src="_images/rurple_book.png" />
180<p class="caption"><span class="caption-text"><em>Two books (red for teacher, blue for students)
181produced by Samsung Korea based on RUR-PLE, the desktop
182program precursor to Reeborg’s World.</em></span></p>
183</div>
184<p>Reeborg’s World had been strongly inspired by Richard Pattis’s
185<a class="reference external" href="https://www.amazon.ca/Karel-Robot-Gentle-Introduction-Programming/dp/0471089281/ref=sr_1_6?s=books&amp;ie=UTF8&amp;qid=1440177128&amp;sr=1-6">Karel the robot</a>.
186Three programming languages (Python, Javascript and CoffeeScript)
187can be used to control the virtual robot.
188However, this tutorial is focuses on Python which is my favourite
189programming language and that many consider to be an ideal language
190to teach programming concepts to beginners.</p>
191<p>In this tutorial, I postpone the introduction of variables as long as
192possible, and do the same for function arguments.
193This approach reflects that of Pattis’s original Karel which did
194not have any variables.  This is the focus of the first two
195main parts of this tutorial, namely <strong>Basic tutorial</strong> and <strong>Recursion</strong>.</p>
196<p>Reeborg’s World has been created with the goal of simplifying Pattis’s
197idea as much as possible, while still making it possible to
198introduce very advanced programming concepts.  So, instead of the
199“simple” <strong>first program</strong> found in some tutorials supposedly aimed
200at complete beginners:</p>
201<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="kd">public</span> <span class="kd">class</span> <span class="nc">HelloWorld</span> <span class="o">{</span>
202    <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="o">(</span><span class="n">String</span><span class="o">[]</span> <span class="n">args</span><span class="o">)</span> <span class="o">{</span>
203        <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">&quot;Hello, World&quot;</span><span class="o">);</span>
204    <span class="o">}</span>
205<span class="o">}</span>
206</pre></div>
207</div>
208<p>the simplest valid program in Reeborg’s World is:</p>
209<div class="highlight-py3 notranslate"><div class="highlight"><pre><span></span><span class="n">move</span><span class="p">()</span>
210</pre></div>
211</div>
212<p>That’s it: a single instruction.  What could be simpler when
213teaching beginners?</p>
214<p>However, one is not limited to simple functions.
215For example, if one wants to use an OOP approach instead,
216the simplest valid program, which has Reeborg actually do the
217equivalent to the single <tt class="docutils literal">move()</tt> instruction above, is:</p>
218<div class="highlight-py3 notranslate"><div class="highlight"><pre><span></span><span class="n">reeborg</span> <span class="o">=</span> <span class="n">UsedRobot</span><span class="p">()</span>
219<span class="n">reeborg</span><span class="o">.</span><span class="n">move</span><span class="p">()</span>
220</pre></div>
221</div>
222<p>Similarly, because using standard libraries is something useful, students
223can first learn about libraries by writing their own code and, in doing so,
224they learn that library modules are just programs like any others.
225Assuming they have defined a function, say <tt class="docutils literal">turn_right()</tt>, in their library,
226the following program will be valid:</p>
227<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">library</span> <span class="kn">import</span> <span class="n">turn_right</span>
228<span class="n">turn_right</span><span class="p">()</span>
229</pre></div>
230</div>
231<p>So, the idea is to have the student deal with as few concepts as possible
232to write programs, only learning new concepts (such as using variables,
233or Object-Oriented notation, or importing code from a library)
234after they have learned the basics.
235One guiding principle in writing this tutorial has been to introduce
236only one programming concept at a time.</p>
237<p>However, the simplicity of the approach used in Reeborg’s World
238does not mean that what can be done is limited to the basics of the
239virtual robot world.
240The Python version of Reeborg’s World is based on <a class="reference external" href="http://brython.info">Brython</a>, and includes
241many Python modules found in Python’s standard library which can be used
242to write advanced programs.</p>
243<p><strong>Task Driven Learning</strong></p>
244<p>Reeborg’s World is designed for <em>Task Driven Learning</em>: students are given
245tasks that Reeborg has to complete, and they must write programs instructing
246Reeborg how to do so.</p>
247<p>Tasks include having Reeborg move objects, build walls, or go to a
248particular location.  Objects in Reeborg’s World are colourful; the
249places they be must moved to by Reeborg are indicated by having a
250picture of the object in shades of grey.</p>
251<img alt="_images/simple_task.gif" src="_images/simple_task.gif" />
252<p>If you have some examples (particularly tasks for Reeborg)
253that you find useful for your students, I would appreciate
254if you could share them with me so as to improve this tutorial.</p>
255<p><strong>Free</strong></p>
256<p class="last">Reeborg’s World is <strong>free</strong>: <em>free</em> to use, <em>free</em> to copy (and put on a school’s
257website), and does not require any registration or login.
258Unlike some other existing code learning website, it does not force
259learners to follow a pre-defined path; educators are <em>free</em> to create their
260own learning material while making use of Reeborg’s World.</p>
261</div>
262</div>
263</div>
264
265
266          </div>
267        </div>
268      </div>  
269      <div class="clearer"></div>
270    </div>
271    <div class="related">
272      <h3>Navigation</h3>
273      <ul>
274        <li class="right" style="margin-right: 10px">
275             <a href="genindex.html" title="General Index"
276             >index</a></li>
277        <li class="right" >
278             <a href="basics/index.html" title="Basic Tutorial"
279             >next</a> |</li>
280        <li><a class="logo" href="/index_en.html" class="fake_button">
281              <img class="logo"  src="_static/robot_e.png" alt="Logo"/>
282              <span class="logo">Reeborg's World</span>
283            </a></li>
284        <li><a href="#">Learn Python with Reeborg</a></li> 
285      </ul>
286    </div>
287    <div class="footer">
288        &copy; Copyright
289          <a href="/cdn-cgi/l/email-protection#42232c2630276c302d202730252702252f232b2e6c212d2f">André Roberge </a>
290        
291       - Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.8.1.
292    </div>
vendor: 111 bytes, lines 292-293
292
293  <script data-cfasync="false" src="/cdn-cgi/scripts/5c5dd728/cloudflare-static/email-decode.min.js"></script>
293<script>
294  $(document).ready(function() {
295      $('.hint').children().hide();
296      $('.hint p.admonition-title').show().css('cursor', 'pointer');
297      $('.hint p.admonition-title').click( function() {$(this).siblings().show().css('cursor', 'auto');})
298      $("a[href^='http']").attr('target','_blank');
299  });
300  </script>
300
301  
301<script type="module" src="https://static.cloudflareinsights.com/beacon.min.js/v31edd6df95cf4e85bb4c19e7a9bdbcba1788362987495" integrity="sha512-iIg7k2xntmwu6/uSb5tpc/hySgZc4eoL31yB29W6tJFo2akwjPWcEqnCEdJvGexCL0KEQwVYv5BlowfhVz26hg==" data-cf-beacon='{"version":"2024.11.0","token":"2b77edce145b45d780a97ab7313bc9cf","r":1,"spa":2}' crossorigin="anonymous"></script>
301
302</body>
303</html>

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.