<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://web.resource.org/cc/" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
  <channel>
    <title>RSS feed for Simple coding</title>
    <link>https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-0</link>
    <description>This RSS feed contains all the sections in Simple coding</description>
    <generator>Moodle</generator>
    <copyright>Copyright © 2015 The Open University</copyright>
    <image>
      <url>https://www.open.edu/openlearn/theme/image.php/_s/openlearnng/core/1664436246/i/rsssitelogo</url>
      <title>moodle</title>
      <link>https://www.open.edu/openlearn</link>
      <width>140</width>
      <height>35</height>
    </image>
    <language>en-gb</language><lastBuildDate>Thu, 20 Oct 2022 16:46:22 +0100</lastBuildDate><pubDate>Thu, 20 Oct 2022 16:46:22 +0100</pubDate><dc:date>2022-10-20T16:46:22+01:00</dc:date><dc:publisher>The Open University</dc:publisher><dc:language>en-gb</dc:language><dc:rights>Copyright © 2015 The Open University</dc:rights><cc:license>Copyright © 2015 The Open University</cc:license><item>
      <title>1 Introduction</title>
      <link>https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-0</link>
      <pubDate>Wed, 05 Dec 2018 12:40:26 GMT</pubDate>
      <description>&lt;p&gt;Software makes the world go round. Cars and TVs have software that controls how they work, and global commerce and finance are impossible without software that control the stocks, carry out payments, find the best transport route, etc.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Coding&lt;/b&gt;&amp;#xA0;(or programming) is the construction of software. Coding involves writing a &amp;#x2018;recipe’, which in computing is called an&amp;#xA0;&lt;b&gt;algorithm&lt;/b&gt;, in a so called&amp;#xA0;&lt;b&gt;programming language&lt;/b&gt;&amp;#xA0;that a computer can understand. When the computer&amp;#xA0;&lt;b&gt;runs&lt;/b&gt;&amp;#xA0;the code we wrote, it follows the &amp;#x2018;recipe’, step by step.&lt;/p&gt;&lt;p&gt;We will use Python, a popular programming language for teaching and for professional software development. You will see that Python code reads almost like plain English. Writing simple programs in Python is not very difficult, once you have come up with the &amp;#x2018;recipe’, the algorithm.&lt;/p&gt;&lt;p&gt;This tutorial shows&amp;#xA0;how to code in Python the basic building blocks of all algorithms, and how to ask the user for input and produce some output on the screen. The skills, concepts and jargon (in boldface) you will learn are the foundations for coding all sorts of apps in all sorts of languages, not just Python.&lt;/p&gt;&lt;p&gt;You won’t have to install any software, the code examples are embedded in this course and you can execute and change them right here.&lt;/p&gt;&lt;div class="oucontent-studynote oucontent-s-gradient oucontent-s-box &amp;#10;        oucontent-s-noheading&amp;#10;      "&gt;&lt;div class="oucontent-outer-box"&gt;&lt;div class="oucontent-inner-box"&gt;&lt;p&gt;Wherever &amp;#x2018;Run Python’ appears we recommend that you open the link in a new tab and work from there.&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;Go ahead, click &amp;#x2018;Run’ (the &amp;#x25BA; icon) to execute the following program (I’ll explain it later). You should see a message showing the output of running the code.&lt;/p&gt;&lt;div id="ds2e" class="oucontent-media oucontent-media-mini"&gt;&lt;div class="oucontent-figure-text"&gt;&lt;div class="oucontent-thumbnaillink oucontent-viewonlineactivity"&gt;&lt;a href="https://www.open.edu/openlearn/mod/oucontent/view.php?id=82140&amp;amp;extra=thumbnail_idm69"&gt;&lt;img src="https://www.open.edu/openlearn/pluginfile.php/1316320/mod_oucontent/oucontent/67640/3e81c503/018e27d9/iframe1.jpg" alt=""/&gt;&lt;br/&gt;View interactive version&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-caption oucontent-nonumber oucontent-caption-placeholder"&gt;&amp;#xA0;&lt;/div&gt;&lt;/div&gt;&lt;a id="back_thumbnail_idm69"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-interaction-print"&gt;&lt;div class="oucontent-interaction-unavailable"&gt;Interactive feature not available in single page view (&lt;a class="oucontent-crossref" href="https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-1#ds2e"&gt;see it in standard view&lt;/a&gt;).&lt;/div&gt;&lt;/div&gt;&lt;p&gt;You can also change the code. Click with the mouse next to the 7 on the first line, and use the keyboard to replace it by 2 (or another number of your choice). Also replace the 7 in the second line by the same number. Click again on &amp;#x2018;Run’. The message should now read &amp;#x201C;The sum of 3 and 2 is 5&amp;#x201D;, or similar.&lt;/p&gt;&lt;p&gt;In the rest of this tutorial I won’t repeat that after you change a program you need to run it to see what it produces.&lt;/p&gt;&lt;p&gt;I will show you various small programs with exercises for you to practice your coding skills, by modifying or building upon my programs. You can share your code with friends and family by clicking on the down arrow next to &amp;#x2018;Share’.&lt;/p&gt;&lt;p&gt;If, whilst practicing, you do any mistakes, you can always undo all your changes. Click on the 3 lines icon in the top left corner. A menu appears. Click on &amp;#x2018;Reset’ and confirm you want to&amp;#xA0;put back the code as it was, before you changed the numbers.&lt;/p&gt;&lt;p&gt;All done? Good. In the next section we will start learning to code.&lt;/p&gt;</description>
      <guid isPermaLink="true">https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-0</guid>
    <dc:title>1 Introduction</dc:title><dc:identifier>SCOD_1</dc:identifier><dc:description>&lt;p&gt;Software makes the world go round. Cars and TVs have software that controls how they work, and global commerce and finance are impossible without software that control the stocks, carry out payments, find the best transport route, etc.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Coding&lt;/b&gt; (or programming) is the construction of software. Coding involves writing a ‘recipe’, which in computing is called an &lt;b&gt;algorithm&lt;/b&gt;, in a so called &lt;b&gt;programming language&lt;/b&gt; that a computer can understand. When the computer &lt;b&gt;runs&lt;/b&gt; the code we wrote, it follows the ‘recipe’, step by step.&lt;/p&gt;&lt;p&gt;We will use Python, a popular programming language for teaching and for professional software development. You will see that Python code reads almost like plain English. Writing simple programs in Python is not very difficult, once you have come up with the ‘recipe’, the algorithm.&lt;/p&gt;&lt;p&gt;This tutorial shows how to code in Python the basic building blocks of all algorithms, and how to ask the user for input and produce some output on the screen. The skills, concepts and jargon (in boldface) you will learn are the foundations for coding all sorts of apps in all sorts of languages, not just Python.&lt;/p&gt;&lt;p&gt;You won’t have to install any software, the code examples are embedded in this course and you can execute and change them right here.&lt;/p&gt;&lt;div class="oucontent-studynote oucontent-s-gradient oucontent-s-box 
        oucontent-s-noheading
      "&gt;&lt;div class="oucontent-outer-box"&gt;&lt;div class="oucontent-inner-box"&gt;&lt;p&gt;Wherever ‘Run Python’ appears we recommend that you open the link in a new tab and work from there.&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;Go ahead, click ‘Run’ (the ► icon) to execute the following program (I’ll explain it later). You should see a message showing the output of running the code.&lt;/p&gt;&lt;div id="ds2e" class="oucontent-media oucontent-media-mini"&gt;&lt;div class="oucontent-figure-text"&gt;&lt;div class="oucontent-thumbnaillink oucontent-viewonlineactivity"&gt;&lt;a href="https://www.open.edu/openlearn/mod/oucontent/view.php?id=82140&amp;extra=thumbnail_idm69"&gt;&lt;img src="https://www.open.edu/openlearn/pluginfile.php/1316320/mod_oucontent/oucontent/67640/3e81c503/018e27d9/iframe1.jpg" alt=""/&gt;&lt;br/&gt;View interactive version&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-caption oucontent-nonumber oucontent-caption-placeholder"&gt; &lt;/div&gt;&lt;/div&gt;&lt;a id="back_thumbnail_idm69"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-interaction-print"&gt;&lt;div class="oucontent-interaction-unavailable"&gt;Interactive feature not available in single page view (&lt;a class="oucontent-crossref" href="https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-1#ds2e"&gt;see it in standard view&lt;/a&gt;).&lt;/div&gt;&lt;/div&gt;&lt;p&gt;You can also change the code. Click with the mouse next to the 7 on the first line, and use the keyboard to replace it by 2 (or another number of your choice). Also replace the 7 in the second line by the same number. Click again on ‘Run’. The message should now read “The sum of 3 and 2 is 5”, or similar.&lt;/p&gt;&lt;p&gt;In the rest of this tutorial I won’t repeat that after you change a program you need to run it to see what it produces.&lt;/p&gt;&lt;p&gt;I will show you various small programs with exercises for you to practice your coding skills, by modifying or building upon my programs. You can share your code with friends and family by clicking on the down arrow next to ‘Share’.&lt;/p&gt;&lt;p&gt;If, whilst practicing, you do any mistakes, you can always undo all your changes. Click on the 3 lines icon in the top left corner. A menu appears. Click on ‘Reset’ and confirm you want to put back the code as it was, before you changed the numbers.&lt;/p&gt;&lt;p&gt;All done? Good. In the next section we will start learning to code.&lt;/p&gt;</dc:description><dc:publisher>The Open University</dc:publisher><dc:creator>The Open University</dc:creator><dc:type>Course</dc:type><dc:format>text/html</dc:format><dc:language>en-GB</dc:language><dc:source>Simple coding - SCOD_1</dc:source><cc:license>Copyright © 2015 The Open University</cc:license></item>
    <item>
      <title>2 Sequence</title>
      <link>https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-2</link>
      <pubDate>Wed, 05 Dec 2018 12:40:26 GMT</pubDate>
      <description>&lt;p&gt;The simplest Python program is a&amp;#xA0;&lt;b&gt;sequence&lt;/b&gt;&amp;#xA0;of&amp;#xA0;&lt;b&gt;instructions&lt;/b&gt;, written one per line, and executed one by one from top to bottom. Our first program only has two instructions. Here is the program again, already run for you. (You may just see the result of running the code. To see the code itself, click on the pencil icon.)&lt;/p&gt;&lt;p&gt;Remember to open the link to Python in a new tab.&lt;/p&gt;&lt;div id="d1e3" class="oucontent-media oucontent-media-mini"&gt;&lt;div class="oucontent-figure-text"&gt;&lt;div class="oucontent-thumbnaillink oucontent-viewonlineactivity"&gt;&lt;a href="https://www.open.edu/openlearn/mod/oucontent/view.php?id=82140&amp;amp;extra=thumbnail_idm83"&gt;&lt;img src="https://www.open.edu/openlearn/pluginfile.php/1316320/mod_oucontent/oucontent/67640/3e81c503/018e27d9/iframe1.jpg" alt=""/&gt;&lt;br/&gt;View interactive version&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-caption oucontent-nonumber oucontent-caption-placeholder"&gt;&amp;#xA0;&lt;/div&gt;&lt;/div&gt;&lt;a id="back_thumbnail_idm83"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-interaction-print"&gt;&lt;div class="oucontent-interaction-unavailable"&gt;Interactive feature not available in single page view (&lt;a class="oucontent-crossref" href="https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-2#d1e3"&gt;see it in standard view&lt;/a&gt;).&lt;/div&gt;&lt;/div&gt;&lt;p&gt;The first instruction is an&amp;#xA0;&lt;b&gt;assignment&lt;/b&gt;: the computer evaluates the&amp;#xA0;&lt;b&gt;expression&lt;/b&gt;&amp;#xA0;to the right of the assignment (=) and stores the result in the&amp;#xA0;&lt;b&gt;variable&lt;/b&gt;&amp;#xA0;on the left of the assignment. Each piece of data we need has to be stored in a variable. Translating Python to English, the assignment states &amp;#x2018;let result be the sum of 3 and 7’.&lt;/p&gt;&lt;p&gt;The second instruction,&amp;#xA0;print, prints some text on the screen, followed by the computed result. Note the following:&lt;/p&gt;&lt;ul class="oucontent-bulleted"&gt;&lt;li&gt;the comma separates the two things to be printed, in the same way we use commas in English to enumerate two, three, or more things;&lt;/li&gt;&lt;li&gt;text is written between double-quotes, which are not printed themselves. In Python, a sequence of characters surrounded by double-quotes is called a&amp;#xA0;&lt;b&gt;string&lt;/b&gt;.&lt;/li&gt;&lt;/ul&gt;</description>
      <guid isPermaLink="true">https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-2</guid>
    <dc:title>2 Sequence</dc:title><dc:identifier>SCOD_1</dc:identifier><dc:description>&lt;p&gt;The simplest Python program is a &lt;b&gt;sequence&lt;/b&gt; of &lt;b&gt;instructions&lt;/b&gt;, written one per line, and executed one by one from top to bottom. Our first program only has two instructions. Here is the program again, already run for you. (You may just see the result of running the code. To see the code itself, click on the pencil icon.)&lt;/p&gt;&lt;p&gt;Remember to open the link to Python in a new tab.&lt;/p&gt;&lt;div id="d1e3" class="oucontent-media oucontent-media-mini"&gt;&lt;div class="oucontent-figure-text"&gt;&lt;div class="oucontent-thumbnaillink oucontent-viewonlineactivity"&gt;&lt;a href="https://www.open.edu/openlearn/mod/oucontent/view.php?id=82140&amp;extra=thumbnail_idm83"&gt;&lt;img src="https://www.open.edu/openlearn/pluginfile.php/1316320/mod_oucontent/oucontent/67640/3e81c503/018e27d9/iframe1.jpg" alt=""/&gt;&lt;br/&gt;View interactive version&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-caption oucontent-nonumber oucontent-caption-placeholder"&gt; &lt;/div&gt;&lt;/div&gt;&lt;a id="back_thumbnail_idm83"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-interaction-print"&gt;&lt;div class="oucontent-interaction-unavailable"&gt;Interactive feature not available in single page view (&lt;a class="oucontent-crossref" href="https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-2#d1e3"&gt;see it in standard view&lt;/a&gt;).&lt;/div&gt;&lt;/div&gt;&lt;p&gt;The first instruction is an &lt;b&gt;assignment&lt;/b&gt;: the computer evaluates the &lt;b&gt;expression&lt;/b&gt; to the right of the assignment (=) and stores the result in the &lt;b&gt;variable&lt;/b&gt; on the left of the assignment. Each piece of data we need has to be stored in a variable. Translating Python to English, the assignment states ‘let result be the sum of 3 and 7’.&lt;/p&gt;&lt;p&gt;The second instruction, print, prints some text on the screen, followed by the computed result. Note the following:&lt;/p&gt;&lt;ul class="oucontent-bulleted"&gt;&lt;li&gt;the comma separates the two things to be printed, in the same way we use commas in English to enumerate two, three, or more things;&lt;/li&gt;&lt;li&gt;text is written between double-quotes, which are not printed themselves. In Python, a sequence of characters surrounded by double-quotes is called a &lt;b&gt;string&lt;/b&gt;.&lt;/li&gt;&lt;/ul&gt;</dc:description><dc:publisher>The Open University</dc:publisher><dc:creator>The Open University</dc:creator><dc:type>Course</dc:type><dc:format>text/html</dc:format><dc:language>en-GB</dc:language><dc:source>Simple coding - SCOD_1</dc:source><cc:license>Copyright © 2015 The Open University</cc:license></item>
    <item>
      <title>2.1 The art of failure</title>
      <link>https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-2.1</link>
      <pubDate>Wed, 05 Dec 2018 12:40:26 GMT</pubDate>
      <description>&lt;p&gt;The following details are important once you start writing code. Computers are not as smart and accommodating as human readers: at the slightest spelling mistake (like&amp;#xA0;pint&amp;#xA0;instead of&amp;#xA0;print) or missing punctuation (forgetting the comma or double-quotes, for example), the computer will give up on understanding and running your code and will display an error message.&lt;/p&gt;&lt;p&gt;On top of that, most error messages are rather cryptic. Hence it’s best to get used to them, by doing errors on purpose, so that you have a clue what might be wrong when you are writing your own code.&lt;/p&gt;&lt;div class="&amp;#10;            oucontent-activity&amp;#10;           oucontent-s-heavybox1 oucontent-s-box "&gt;&lt;div class="oucontent-outer-box"&gt;&lt;h2 class="oucontent-h3 oucontent-heading oucontent-nonumber"&gt;Activity 1&lt;/h2&gt;&lt;div class="oucontent-inner-box"&gt;&lt;div class="oucontent-saq-question"&gt;
&lt;p&gt;Put double-quotes around the 7 on the first line and run the program. You will get an error message saying that there is a&amp;#xA0;&lt;b&gt;type error&lt;/b&gt;. This basically means the code is mixing data of different types, mixing apples and oranges if you like. In this case, we are trying to add a number (&lt;span class="oucontent-computercode"&gt;3&lt;/span&gt;) to a string (&lt;span class="oucontent-computercode"&gt;"7"&lt;/span&gt;) which of course doesn’t make sense. Click on the X at the right end of the message to make it go away and then reset the program to undo the change.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;Sometimes, code has more subtle errors, that lead to unexpected results. This is akin to miscommunication, when other people understand something different from what you intended to say. Here is an example.&lt;/p&gt;&lt;div class="&amp;#10;            oucontent-activity&amp;#10;           oucontent-s-heavybox1 oucontent-s-box "&gt;&lt;div class="oucontent-outer-box"&gt;&lt;h2 class="oucontent-h3 oucontent-heading oucontent-nonumber"&gt;Activity 2&lt;/h2&gt;&lt;div class="oucontent-inner-box"&gt;&lt;div class="oucontent-saq-question"&gt;
&lt;p&gt;Put double-quotes around the variable name in the second line. Run the program. Try to explain what happened before reading further.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;When putting double-quotes around the variable name, it becomes a string. Hence, the computer will print the name literally, instead of printing the value stored in the variable.&lt;/p&gt;&lt;p&gt;To sum up,&amp;#xA0;&lt;span class="oucontent-computercode"&gt;"result"&lt;/span&gt;,&lt;span class="oucontent-computercode"&gt;&amp;#xA0;"7"&lt;/span&gt;,&amp;#xA0;&lt;span class="oucontent-computercode"&gt;result&lt;/span&gt;&amp;#xA0;and&amp;#xA0;&lt;span class="oucontent-computercode"&gt;7&lt;/span&gt;&amp;#xA0;are different things: the first two are strings (literal text), the third is a variable, and the last is a number.&lt;/p&gt;&lt;p&gt;Learning from mistakes is always helpful, so for this and the remaining programs in this tutorial, I encourage you to introduce errors and observe what message or output you get. Don’t forget to reset the program after each error.&lt;/p&gt;&lt;p&gt;In a sequence,&amp;#xA0;&lt;i&gt;all&lt;/i&gt;&amp;#xA0;instructions are executed. Next you will learn how to selectively execute some instructions but not others.&lt;/p&gt;</description>
      <guid isPermaLink="true">https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-2.1</guid>
    <dc:title>2.1 The art of failure</dc:title><dc:identifier>SCOD_1</dc:identifier><dc:description>&lt;p&gt;The following details are important once you start writing code. Computers are not as smart and accommodating as human readers: at the slightest spelling mistake (like pint instead of print) or missing punctuation (forgetting the comma or double-quotes, for example), the computer will give up on understanding and running your code and will display an error message.&lt;/p&gt;&lt;p&gt;On top of that, most error messages are rather cryptic. Hence it’s best to get used to them, by doing errors on purpose, so that you have a clue what might be wrong when you are writing your own code.&lt;/p&gt;&lt;div class="
            oucontent-activity
           oucontent-s-heavybox1 oucontent-s-box "&gt;&lt;div class="oucontent-outer-box"&gt;&lt;h2 class="oucontent-h3 oucontent-heading oucontent-nonumber"&gt;Activity 1&lt;/h2&gt;&lt;div class="oucontent-inner-box"&gt;&lt;div class="oucontent-saq-question"&gt;
&lt;p&gt;Put double-quotes around the 7 on the first line and run the program. You will get an error message saying that there is a &lt;b&gt;type error&lt;/b&gt;. This basically means the code is mixing data of different types, mixing apples and oranges if you like. In this case, we are trying to add a number (&lt;span class="oucontent-computercode"&gt;3&lt;/span&gt;) to a string (&lt;span class="oucontent-computercode"&gt;"7"&lt;/span&gt;) which of course doesn’t make sense. Click on the X at the right end of the message to make it go away and then reset the program to undo the change.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;Sometimes, code has more subtle errors, that lead to unexpected results. This is akin to miscommunication, when other people understand something different from what you intended to say. Here is an example.&lt;/p&gt;&lt;div class="
            oucontent-activity
           oucontent-s-heavybox1 oucontent-s-box "&gt;&lt;div class="oucontent-outer-box"&gt;&lt;h2 class="oucontent-h3 oucontent-heading oucontent-nonumber"&gt;Activity 2&lt;/h2&gt;&lt;div class="oucontent-inner-box"&gt;&lt;div class="oucontent-saq-question"&gt;
&lt;p&gt;Put double-quotes around the variable name in the second line. Run the program. Try to explain what happened before reading further.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;When putting double-quotes around the variable name, it becomes a string. Hence, the computer will print the name literally, instead of printing the value stored in the variable.&lt;/p&gt;&lt;p&gt;To sum up, &lt;span class="oucontent-computercode"&gt;"result"&lt;/span&gt;,&lt;span class="oucontent-computercode"&gt; "7"&lt;/span&gt;, &lt;span class="oucontent-computercode"&gt;result&lt;/span&gt; and &lt;span class="oucontent-computercode"&gt;7&lt;/span&gt; are different things: the first two are strings (literal text), the third is a variable, and the last is a number.&lt;/p&gt;&lt;p&gt;Learning from mistakes is always helpful, so for this and the remaining programs in this tutorial, I encourage you to introduce errors and observe what message or output you get. Don’t forget to reset the program after each error.&lt;/p&gt;&lt;p&gt;In a sequence, &lt;i&gt;all&lt;/i&gt; instructions are executed. Next you will learn how to selectively execute some instructions but not others.&lt;/p&gt;</dc:description><dc:publisher>The Open University</dc:publisher><dc:creator>The Open University</dc:creator><dc:type>Course</dc:type><dc:format>text/html</dc:format><dc:language>en-GB</dc:language><dc:source>Simple coding - SCOD_1</dc:source><cc:license>Copyright © 2015 The Open University</cc:license></item>
    <item>
      <title>3 Selection</title>
      <link>https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-3</link>
      <pubDate>Wed, 05 Dec 2018 12:40:26 GMT</pubDate>
      <description>&lt;p&gt;Further investigate the Python programming language by learning about conditions.&amp;#xA0;&lt;/p&gt;&lt;p&gt;Let’s imagine we are developing software for a restaurant, where a tip of 10% is added to the bill. Here’s the code, a simple sequence of assignments and output. For example, the assignment on line 3 states &amp;#x2018;let the tip be the expenses multiplied by the percentage’. Note that in Python the&amp;#xA0;&lt;b&gt;multiplication operator&lt;/b&gt;&amp;#xA0;is the asterisk.&lt;/p&gt;&lt;div id="te23" class="oucontent-media oucontent-media-mini"&gt;&lt;div class="oucontent-figure-text"&gt;&lt;div class="oucontent-thumbnaillink oucontent-viewonlineactivity"&gt;&lt;a href="https://www.open.edu/openlearn/mod/oucontent/view.php?id=82140&amp;amp;extra=thumbnail_idm125"&gt;&lt;img src="https://www.open.edu/openlearn/pluginfile.php/1316320/mod_oucontent/oucontent/67640/3e81c503/018e27d9/iframe1.jpg" alt=""/&gt;&lt;br/&gt;View interactive version&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-caption oucontent-nonumber oucontent-caption-placeholder"&gt;&amp;#xA0;&lt;/div&gt;&lt;/div&gt;&lt;a id="back_thumbnail_idm125"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-interaction-print"&gt;&lt;div class="oucontent-interaction-unavailable"&gt;Interactive feature not available in single page view (&lt;a class="oucontent-crossref" href="https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-3#te23"&gt;see it in standard view&lt;/a&gt;).&lt;/div&gt;&lt;/div&gt;&lt;p&gt;Let’s further assume the tip is only automatically added for groups above 6 people. We need one more variable, to store the number of people in the group, and one new instruction to handle both cases:&amp;#xA0;&lt;i&gt;if&lt;/i&gt;&amp;#xA0;the number of people is more than 6, the percentage is 10%,&amp;#xA0;&lt;i&gt;otherwise&lt;/i&gt;&amp;#xA0;it’s 0%.&lt;/p&gt;&lt;div id="dse3d" class="oucontent-media oucontent-media-mini"&gt;&lt;div class="oucontent-figure-text"&gt;&lt;div class="oucontent-thumbnaillink oucontent-viewonlineactivity"&gt;&lt;a href="https://www.open.edu/openlearn/mod/oucontent/view.php?id=82140&amp;amp;extra=thumbnail_idm131"&gt;&lt;img src="https://www.open.edu/openlearn/pluginfile.php/1316320/mod_oucontent/oucontent/67640/3e81c503/018e27d9/iframe1.jpg" alt=""/&gt;&lt;br/&gt;View interactive version&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-caption oucontent-nonumber oucontent-caption-placeholder"&gt;&amp;#xA0;&lt;/div&gt;&lt;/div&gt;&lt;a id="back_thumbnail_idm131"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-interaction-print"&gt;&lt;div class="oucontent-interaction-unavailable"&gt;Interactive feature not available in single page view (&lt;a class="oucontent-crossref" href="https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-3#dse3d"&gt;see it in standard view&lt;/a&gt;).&lt;/div&gt;&lt;/div&gt;&lt;p&gt;Before I explain the code, let’s&amp;#xA0;&lt;b&gt;test&lt;/b&gt;&amp;#xA0;it, to make sure it works as intended. Large software companies employ many testers to check their code. Good testing includes choosing enough inputs (preferably borderline cases) to exercise all possible conditions. In this case, we should at least test for 6 and 7 people, the borderlines where the tip percentage changes.&lt;/p&gt;&lt;div class="&amp;#10;            oucontent-activity&amp;#10;           oucontent-s-heavybox1 oucontent-s-box "&gt;&lt;div class="oucontent-outer-box"&gt;&lt;h2 class="oucontent-h3 oucontent-heading oucontent-nonumber"&gt;Activity 3&lt;/h2&gt;&lt;div class="oucontent-inner-box"&gt;&lt;div class="oucontent-saq-question"&gt;
&lt;p&gt;Change the number of people to 6 and confirm the bill is just the expenses in that case.&lt;/p&gt;
&lt;p&gt;Notice there is a colon (&lt;span class="oucontent-computercode"&gt;:&lt;/span&gt;) at the end of the&amp;#xA0;&lt;span class="oucontent-computercode"&gt;if&lt;/span&gt;&amp;#xA0;and&amp;#xA0;&lt;span class="oucontent-computercode"&gt;else&lt;/span&gt;&amp;#xA0;lines. Forgetting the colons and forgetting to indent the instructions will lead to error messages.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;The&lt;b&gt;&amp;#xA0;selection&lt;/b&gt;&amp;#xA0;instruction &amp;#x2018;&lt;span class="oucontent-computercode"&gt;if&lt;/span&gt;&amp;#xA0;condition:&amp;#xA0;block&lt;span class="oucontent-computercode"&gt;&amp;#xA0;else&lt;/span&gt;:&amp;#xA0;block’ chooses which block to execute&amp;#xA0;as follows. The computer checks the condition after the&amp;#xA0;if. If it is true, the computer then executes the&amp;#xA0;&lt;b&gt;block&lt;/b&gt;&amp;#xA0;of code (the indented instructions) belonging to the&amp;#xA0;if&amp;#xA0;part. If the condition is false, the computer executes&amp;#xA0;&lt;i&gt;instead&lt;/i&gt;&amp;#xA0;the&amp;#xA0;&lt;span class="oucontent-computercode"&gt;else&amp;#xA0;&lt;/span&gt;block. The indentation is needed to know which instructions belong to which part. Afterwards the computer continues executing the non-indented instructions.&lt;/p&gt;</description>
      <guid isPermaLink="true">https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-3</guid>
    <dc:title>3 Selection</dc:title><dc:identifier>SCOD_1</dc:identifier><dc:description>&lt;p&gt;Further investigate the Python programming language by learning about conditions. &lt;/p&gt;&lt;p&gt;Let’s imagine we are developing software for a restaurant, where a tip of 10% is added to the bill. Here’s the code, a simple sequence of assignments and output. For example, the assignment on line 3 states ‘let the tip be the expenses multiplied by the percentage’. Note that in Python the &lt;b&gt;multiplication operator&lt;/b&gt; is the asterisk.&lt;/p&gt;&lt;div id="te23" class="oucontent-media oucontent-media-mini"&gt;&lt;div class="oucontent-figure-text"&gt;&lt;div class="oucontent-thumbnaillink oucontent-viewonlineactivity"&gt;&lt;a href="https://www.open.edu/openlearn/mod/oucontent/view.php?id=82140&amp;extra=thumbnail_idm125"&gt;&lt;img src="https://www.open.edu/openlearn/pluginfile.php/1316320/mod_oucontent/oucontent/67640/3e81c503/018e27d9/iframe1.jpg" alt=""/&gt;&lt;br/&gt;View interactive version&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-caption oucontent-nonumber oucontent-caption-placeholder"&gt; &lt;/div&gt;&lt;/div&gt;&lt;a id="back_thumbnail_idm125"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-interaction-print"&gt;&lt;div class="oucontent-interaction-unavailable"&gt;Interactive feature not available in single page view (&lt;a class="oucontent-crossref" href="https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-3#te23"&gt;see it in standard view&lt;/a&gt;).&lt;/div&gt;&lt;/div&gt;&lt;p&gt;Let’s further assume the tip is only automatically added for groups above 6 people. We need one more variable, to store the number of people in the group, and one new instruction to handle both cases: &lt;i&gt;if&lt;/i&gt; the number of people is more than 6, the percentage is 10%, &lt;i&gt;otherwise&lt;/i&gt; it’s 0%.&lt;/p&gt;&lt;div id="dse3d" class="oucontent-media oucontent-media-mini"&gt;&lt;div class="oucontent-figure-text"&gt;&lt;div class="oucontent-thumbnaillink oucontent-viewonlineactivity"&gt;&lt;a href="https://www.open.edu/openlearn/mod/oucontent/view.php?id=82140&amp;extra=thumbnail_idm131"&gt;&lt;img src="https://www.open.edu/openlearn/pluginfile.php/1316320/mod_oucontent/oucontent/67640/3e81c503/018e27d9/iframe1.jpg" alt=""/&gt;&lt;br/&gt;View interactive version&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-caption oucontent-nonumber oucontent-caption-placeholder"&gt; &lt;/div&gt;&lt;/div&gt;&lt;a id="back_thumbnail_idm131"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-interaction-print"&gt;&lt;div class="oucontent-interaction-unavailable"&gt;Interactive feature not available in single page view (&lt;a class="oucontent-crossref" href="https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-3#dse3d"&gt;see it in standard view&lt;/a&gt;).&lt;/div&gt;&lt;/div&gt;&lt;p&gt;Before I explain the code, let’s &lt;b&gt;test&lt;/b&gt; it, to make sure it works as intended. Large software companies employ many testers to check their code. Good testing includes choosing enough inputs (preferably borderline cases) to exercise all possible conditions. In this case, we should at least test for 6 and 7 people, the borderlines where the tip percentage changes.&lt;/p&gt;&lt;div class="
            oucontent-activity
           oucontent-s-heavybox1 oucontent-s-box "&gt;&lt;div class="oucontent-outer-box"&gt;&lt;h2 class="oucontent-h3 oucontent-heading oucontent-nonumber"&gt;Activity 3&lt;/h2&gt;&lt;div class="oucontent-inner-box"&gt;&lt;div class="oucontent-saq-question"&gt;
&lt;p&gt;Change the number of people to 6 and confirm the bill is just the expenses in that case.&lt;/p&gt;
&lt;p&gt;Notice there is a colon (&lt;span class="oucontent-computercode"&gt;:&lt;/span&gt;) at the end of the &lt;span class="oucontent-computercode"&gt;if&lt;/span&gt; and &lt;span class="oucontent-computercode"&gt;else&lt;/span&gt; lines. Forgetting the colons and forgetting to indent the instructions will lead to error messages.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;The&lt;b&gt; selection&lt;/b&gt; instruction ‘&lt;span class="oucontent-computercode"&gt;if&lt;/span&gt; condition: block&lt;span class="oucontent-computercode"&gt; else&lt;/span&gt;: block’ chooses which block to execute as follows. The computer checks the condition after the if. If it is true, the computer then executes the &lt;b&gt;block&lt;/b&gt; of code (the indented instructions) belonging to the if part. If the condition is false, the computer executes &lt;i&gt;instead&lt;/i&gt; the &lt;span class="oucontent-computercode"&gt;else &lt;/span&gt;block. The indentation is needed to know which instructions belong to which part. Afterwards the computer continues executing the non-indented instructions.&lt;/p&gt;</dc:description><dc:publisher>The Open University</dc:publisher><dc:creator>The Open University</dc:creator><dc:type>Course</dc:type><dc:format>text/html</dc:format><dc:language>en-GB</dc:language><dc:source>Simple coding - SCOD_1</dc:source><cc:license>Copyright © 2015 The Open University</cc:license></item>
    <item>
      <title>3.1 And now for something not completely different</title>
      <link>https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-3.1</link>
      <pubDate>Wed, 05 Dec 2018 12:40:26 GMT</pubDate>
      <description>&lt;p&gt;Usually there are many ways to solve the same problem. For the problem of adding the 10% tip only to groups over 6 people, we have set the tip rate to 0% or 10% or the tip itself but we can instead change how the tip is calculated.&lt;/p&gt;&lt;div class="&amp;#10;            oucontent-activity&amp;#10;           oucontent-s-heavybox1 oucontent-s-box "&gt;&lt;div class="oucontent-outer-box"&gt;&lt;h2 class="oucontent-h3 oucontent-heading oucontent-nonumber"&gt;Activity 4&lt;/h2&gt;&lt;div class="oucontent-inner-box"&gt;&lt;div class="oucontent-saq-question"&gt;
&lt;p&gt;Keep the rate at 10% but change the way the tip is computed: if there are more than 6 people, let the tip be the expenses times the rate, otherwise let the tip be zero. Change the code accordingly and check your solution against&amp;#xA0;&lt;span class="oucontent-linkwithtip"&gt;&lt;a class="oucontent-hyperlink" href="https://trinket.io/python/0c2f220d84"&gt;mine&amp;#xA0;&lt;/a&gt;&lt;/span&gt;.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;Finally, let’s assume the restaurant decides to impose a higher tip of 15% for groups of at least 15 people. In Python we can chain various conditions as follows:&lt;/p&gt;&lt;div id="s2a3" class="oucontent-media oucontent-media-mini"&gt;&lt;div class="oucontent-figure-text"&gt;&lt;div class="oucontent-thumbnaillink oucontent-viewonlineactivity"&gt;&lt;a href="https://www.open.edu/openlearn/mod/oucontent/view.php?id=82140&amp;amp;extra=thumbnail_idm160"&gt;&lt;img src="https://www.open.edu/openlearn/pluginfile.php/1316320/mod_oucontent/oucontent/67640/3e81c503/018e27d9/iframe1.jpg" alt=""/&gt;&lt;br/&gt;View interactive version&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-caption oucontent-nonumber oucontent-caption-placeholder"&gt;&amp;#xA0;&lt;/div&gt;&lt;/div&gt;&lt;a id="back_thumbnail_idm160"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-interaction-print"&gt;&lt;div class="oucontent-interaction-unavailable"&gt;Interactive feature not available in single page view (&lt;a class="oucontent-crossref" href="https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-3.1#s2a3"&gt;see it in standard view&lt;/a&gt;).&lt;/div&gt;&lt;/div&gt;&lt;p&gt;In plain English: if the number of people is larger or equal (&lt;span class="oucontent-computercode"&gt;&amp;gt;=&lt;/span&gt;) to 15, let the percentage be 15%, otherwise if (&lt;span class="oucontent-computercode"&gt;elif&lt;/span&gt;,&amp;#xA0;&lt;i&gt;not&lt;/i&gt;&amp;#xA0;&lt;span class="oucontent-computercode"&gt;else if&lt;/span&gt;) it is larger than 6 let the percentage be 10%, otherwise let the percentage be 0%.&lt;/p&gt;&lt;div class="&amp;#10;            oucontent-activity&amp;#10;           oucontent-s-heavybox1 oucontent-s-box "&gt;&lt;div class="oucontent-outer-box"&gt;&lt;h2 class="oucontent-h3 oucontent-heading oucontent-nonumber"&gt;Activity 5&lt;/h2&gt;&lt;div class="oucontent-inner-box"&gt;&lt;div class="oucontent-saq-question"&gt;
&lt;p&gt;Test the code with the four borderline cases: 6, 7, 14 and 15 people.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;Note that the order in which we write the conditions is important, because the computer checks them from top to bottom and executes only&amp;#xA0;&lt;i&gt;one&lt;/i&gt;&amp;#xA0;block, for the&amp;#xA0;&lt;i&gt;first&lt;/i&gt;&amp;#xA0;condition that is true. The&amp;#xA0;&lt;span class="oucontent-computercode"&gt;else&lt;/span&gt;&amp;#xA0;block has no condition, so it’s a &amp;#x2018;catch all’ in case no condition is true.&lt;/p&gt;&lt;div class="&amp;#10;            oucontent-activity&amp;#10;           oucontent-s-heavybox1 oucontent-s-box "&gt;&lt;div class="oucontent-outer-box"&gt;&lt;h2 class="oucontent-h3 oucontent-heading oucontent-nonumber"&gt;Activity 6&lt;/h2&gt;&lt;div class="oucontent-inner-box"&gt;&lt;div class="oucontent-saq-question"&gt;
&lt;p&gt;Explain why the following code is wrong. Hint: repeat the tests and see what happens. That’s what tests are for.&lt;/p&gt;
&lt;div id="sww3" class="oucontent-media oucontent-media-mini"&gt;&lt;div class="oucontent-figure-text"&gt;&lt;div class="oucontent-thumbnaillink oucontent-viewonlineactivity"&gt;&lt;a href="https://www.open.edu/openlearn/mod/oucontent/view.php?id=82140&amp;amp;extra=thumbnail_idm180"&gt;&lt;img src="https://www.open.edu/openlearn/pluginfile.php/1316320/mod_oucontent/oucontent/67640/3e81c503/018e27d9/iframe1.jpg" alt=""/&gt;&lt;br/&gt;View interactive version&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-caption oucontent-nonumber oucontent-caption-placeholder"&gt;&amp;#xA0;&lt;/div&gt;&lt;/div&gt;&lt;a id="back_thumbnail_idm180"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-interaction-print"&gt;&lt;div class="oucontent-interaction-unavailable"&gt;Interactive feature not available in single page view (&lt;a class="oucontent-crossref" href="https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-3.1#sww3"&gt;see it in standard view&lt;/a&gt;).&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
      <guid isPermaLink="true">https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-3.1</guid>
    <dc:title>3.1 And now for something not completely different</dc:title><dc:identifier>SCOD_1</dc:identifier><dc:description>&lt;p&gt;Usually there are many ways to solve the same problem. For the problem of adding the 10% tip only to groups over 6 people, we have set the tip rate to 0% or 10% or the tip itself but we can instead change how the tip is calculated.&lt;/p&gt;&lt;div class="
            oucontent-activity
           oucontent-s-heavybox1 oucontent-s-box "&gt;&lt;div class="oucontent-outer-box"&gt;&lt;h2 class="oucontent-h3 oucontent-heading oucontent-nonumber"&gt;Activity 4&lt;/h2&gt;&lt;div class="oucontent-inner-box"&gt;&lt;div class="oucontent-saq-question"&gt;
&lt;p&gt;Keep the rate at 10% but change the way the tip is computed: if there are more than 6 people, let the tip be the expenses times the rate, otherwise let the tip be zero. Change the code accordingly and check your solution against &lt;span class="oucontent-linkwithtip"&gt;&lt;a class="oucontent-hyperlink" href="https://trinket.io/python/0c2f220d84"&gt;mine &lt;/a&gt;&lt;/span&gt;.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;Finally, let’s assume the restaurant decides to impose a higher tip of 15% for groups of at least 15 people. In Python we can chain various conditions as follows:&lt;/p&gt;&lt;div id="s2a3" class="oucontent-media oucontent-media-mini"&gt;&lt;div class="oucontent-figure-text"&gt;&lt;div class="oucontent-thumbnaillink oucontent-viewonlineactivity"&gt;&lt;a href="https://www.open.edu/openlearn/mod/oucontent/view.php?id=82140&amp;extra=thumbnail_idm160"&gt;&lt;img src="https://www.open.edu/openlearn/pluginfile.php/1316320/mod_oucontent/oucontent/67640/3e81c503/018e27d9/iframe1.jpg" alt=""/&gt;&lt;br/&gt;View interactive version&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-caption oucontent-nonumber oucontent-caption-placeholder"&gt; &lt;/div&gt;&lt;/div&gt;&lt;a id="back_thumbnail_idm160"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-interaction-print"&gt;&lt;div class="oucontent-interaction-unavailable"&gt;Interactive feature not available in single page view (&lt;a class="oucontent-crossref" href="https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-3.1#s2a3"&gt;see it in standard view&lt;/a&gt;).&lt;/div&gt;&lt;/div&gt;&lt;p&gt;In plain English: if the number of people is larger or equal (&lt;span class="oucontent-computercode"&gt;&gt;=&lt;/span&gt;) to 15, let the percentage be 15%, otherwise if (&lt;span class="oucontent-computercode"&gt;elif&lt;/span&gt;, &lt;i&gt;not&lt;/i&gt; &lt;span class="oucontent-computercode"&gt;else if&lt;/span&gt;) it is larger than 6 let the percentage be 10%, otherwise let the percentage be 0%.&lt;/p&gt;&lt;div class="
            oucontent-activity
           oucontent-s-heavybox1 oucontent-s-box "&gt;&lt;div class="oucontent-outer-box"&gt;&lt;h2 class="oucontent-h3 oucontent-heading oucontent-nonumber"&gt;Activity 5&lt;/h2&gt;&lt;div class="oucontent-inner-box"&gt;&lt;div class="oucontent-saq-question"&gt;
&lt;p&gt;Test the code with the four borderline cases: 6, 7, 14 and 15 people.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;Note that the order in which we write the conditions is important, because the computer checks them from top to bottom and executes only &lt;i&gt;one&lt;/i&gt; block, for the &lt;i&gt;first&lt;/i&gt; condition that is true. The &lt;span class="oucontent-computercode"&gt;else&lt;/span&gt; block has no condition, so it’s a ‘catch all’ in case no condition is true.&lt;/p&gt;&lt;div class="
            oucontent-activity
           oucontent-s-heavybox1 oucontent-s-box "&gt;&lt;div class="oucontent-outer-box"&gt;&lt;h2 class="oucontent-h3 oucontent-heading oucontent-nonumber"&gt;Activity 6&lt;/h2&gt;&lt;div class="oucontent-inner-box"&gt;&lt;div class="oucontent-saq-question"&gt;
&lt;p&gt;Explain why the following code is wrong. Hint: repeat the tests and see what happens. That’s what tests are for.&lt;/p&gt;
&lt;div id="sww3" class="oucontent-media oucontent-media-mini"&gt;&lt;div class="oucontent-figure-text"&gt;&lt;div class="oucontent-thumbnaillink oucontent-viewonlineactivity"&gt;&lt;a href="https://www.open.edu/openlearn/mod/oucontent/view.php?id=82140&amp;extra=thumbnail_idm180"&gt;&lt;img src="https://www.open.edu/openlearn/pluginfile.php/1316320/mod_oucontent/oucontent/67640/3e81c503/018e27d9/iframe1.jpg" alt=""/&gt;&lt;br/&gt;View interactive version&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-caption oucontent-nonumber oucontent-caption-placeholder"&gt; &lt;/div&gt;&lt;/div&gt;&lt;a id="back_thumbnail_idm180"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-interaction-print"&gt;&lt;div class="oucontent-interaction-unavailable"&gt;Interactive feature not available in single page view (&lt;a class="oucontent-crossref" href="https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-3.1#sww3"&gt;see it in standard view&lt;/a&gt;).&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</dc:description><dc:publisher>The Open University</dc:publisher><dc:creator>The Open University</dc:creator><dc:type>Course</dc:type><dc:format>text/html</dc:format><dc:language>en-GB</dc:language><dc:source>Simple coding - SCOD_1</dc:source><cc:license>Copyright © 2015 The Open University</cc:license></item>
    <item>
      <title>4 Iteration (part 1)</title>
      <link>https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-4</link>
      <pubDate>Wed, 05 Dec 2018 12:40:26 GMT</pubDate>
      <description>&lt;p&gt;In this section you will learn about repetition in the Python programming language.&amp;#xA0;&lt;/p&gt;&lt;p&gt;A restaurant bill is made from the various food and drink items ordered. Our program should sum those prices to obtain the expenses, on which the tip will then be added. The algorithm (which is independent of any programming language) is as follows.&lt;/p&gt;&lt;ol class="oucontent-numbered"&gt;&lt;li&gt;Let items be a list of the prices of the food and drinks ordered.&lt;/li&gt;&lt;li&gt;Let the expenses be zero.&lt;/li&gt;&lt;li&gt;For each item in the items list:&lt;ul class="oucontent-bulleted"&gt;&lt;li&gt;add it to the expenses.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;print the expenses&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Step 3 is called an&amp;#xA0;&lt;b&gt;iteration&lt;/b&gt;:&amp;#xA0;it goes through the list to process each item.&amp;#xA0;This can be directly translated to Python.&lt;/p&gt;&lt;div id="gg32" class="oucontent-media oucontent-media-mini"&gt;&lt;div class="oucontent-figure-text"&gt;&lt;div class="oucontent-thumbnaillink oucontent-viewonlineactivity"&gt;&lt;a href="https://www.open.edu/openlearn/mod/oucontent/view.php?id=82140&amp;amp;extra=thumbnail_idm196"&gt;&lt;img src="https://www.open.edu/openlearn/pluginfile.php/1316320/mod_oucontent/oucontent/67640/3e81c503/018e27d9/iframe1.jpg" alt=""/&gt;&lt;br/&gt;View interactive version&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-caption oucontent-nonumber oucontent-caption-placeholder"&gt;&amp;#xA0;&lt;/div&gt;&lt;/div&gt;&lt;a id="back_thumbnail_idm196"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-interaction-print"&gt;&lt;div class="oucontent-interaction-unavailable"&gt;Interactive feature not available in single page view (&lt;a class="oucontent-crossref" href="https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-4#gg32"&gt;see it in standard view&lt;/a&gt;).&lt;/div&gt;&lt;/div&gt;&lt;p&gt;In Python, any line starting with&amp;#xA0;#&amp;#xA0;is a&amp;#xA0;&lt;b&gt;comment&lt;/b&gt;. The computer ignores comments, they are just notes by the code’s author to clarify any finer points. Such notes come in very handy if the author (or someone else) needs to change the code later.&lt;/p&gt;&lt;p&gt;In Python,&amp;#xA0;&lt;b&gt;lists&lt;/b&gt;&amp;#xA0;are simply comma-separated values, within square brackets.&lt;/p&gt;&lt;p&gt;The &amp;#x2018;for&amp;#xA0;variable&amp;#xA0;in&amp;#xA0;list:&amp;#xA0;block’ instruction goes through the given list and successively stores each value of the list in the variable and then executes the block, which will usually (but not always, see the exercise below) refer to the variable to get its value. In this case, I add the value of the item to the current expenses and store the result again in expenses, so that it is always up to date. In English: let the new expenses be the old expenses plus the item ordered.&lt;/p&gt;&lt;div class="&amp;#10;            oucontent-activity&amp;#10;           oucontent-s-heavybox1 oucontent-s-box "&gt;&lt;div class="oucontent-outer-box"&gt;&lt;h2 class="oucontent-h3 oucontent-heading oucontent-nonumber"&gt;Activity 7&lt;/h2&gt;&lt;div class="oucontent-inner-box"&gt;&lt;div class="oucontent-saq-question"&gt;
&lt;p&gt;Calculate and print how many items were ordered, i.e. 5 in the example above. First change the algorithm, then translate it to code. Hint: you need to count the items in the list, their prices are irrelevant. If you get stuck, you can see the&amp;#xA0;&lt;span class="oucontent-linkwithtip"&gt;&lt;a class="oucontent-hyperlink" href="https://trinket.io/python/aa5874c884"&gt;algorithm&amp;#xA0;&lt;/a&gt;&lt;/span&gt;.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
      <guid isPermaLink="true">https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-4</guid>
    <dc:title>4 Iteration (part 1)</dc:title><dc:identifier>SCOD_1</dc:identifier><dc:description>&lt;p&gt;In this section you will learn about repetition in the Python programming language. &lt;/p&gt;&lt;p&gt;A restaurant bill is made from the various food and drink items ordered. Our program should sum those prices to obtain the expenses, on which the tip will then be added. The algorithm (which is independent of any programming language) is as follows.&lt;/p&gt;&lt;ol class="oucontent-numbered"&gt;&lt;li&gt;Let items be a list of the prices of the food and drinks ordered.&lt;/li&gt;&lt;li&gt;Let the expenses be zero.&lt;/li&gt;&lt;li&gt;For each item in the items list:&lt;ul class="oucontent-bulleted"&gt;&lt;li&gt;add it to the expenses.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;print the expenses&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Step 3 is called an &lt;b&gt;iteration&lt;/b&gt;: it goes through the list to process each item. This can be directly translated to Python.&lt;/p&gt;&lt;div id="gg32" class="oucontent-media oucontent-media-mini"&gt;&lt;div class="oucontent-figure-text"&gt;&lt;div class="oucontent-thumbnaillink oucontent-viewonlineactivity"&gt;&lt;a href="https://www.open.edu/openlearn/mod/oucontent/view.php?id=82140&amp;extra=thumbnail_idm196"&gt;&lt;img src="https://www.open.edu/openlearn/pluginfile.php/1316320/mod_oucontent/oucontent/67640/3e81c503/018e27d9/iframe1.jpg" alt=""/&gt;&lt;br/&gt;View interactive version&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-caption oucontent-nonumber oucontent-caption-placeholder"&gt; &lt;/div&gt;&lt;/div&gt;&lt;a id="back_thumbnail_idm196"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-interaction-print"&gt;&lt;div class="oucontent-interaction-unavailable"&gt;Interactive feature not available in single page view (&lt;a class="oucontent-crossref" href="https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-4#gg32"&gt;see it in standard view&lt;/a&gt;).&lt;/div&gt;&lt;/div&gt;&lt;p&gt;In Python, any line starting with # is a &lt;b&gt;comment&lt;/b&gt;. The computer ignores comments, they are just notes by the code’s author to clarify any finer points. Such notes come in very handy if the author (or someone else) needs to change the code later.&lt;/p&gt;&lt;p&gt;In Python, &lt;b&gt;lists&lt;/b&gt; are simply comma-separated values, within square brackets.&lt;/p&gt;&lt;p&gt;The ‘for variable in list: block’ instruction goes through the given list and successively stores each value of the list in the variable and then executes the block, which will usually (but not always, see the exercise below) refer to the variable to get its value. In this case, I add the value of the item to the current expenses and store the result again in expenses, so that it is always up to date. In English: let the new expenses be the old expenses plus the item ordered.&lt;/p&gt;&lt;div class="
            oucontent-activity
           oucontent-s-heavybox1 oucontent-s-box "&gt;&lt;div class="oucontent-outer-box"&gt;&lt;h2 class="oucontent-h3 oucontent-heading oucontent-nonumber"&gt;Activity 7&lt;/h2&gt;&lt;div class="oucontent-inner-box"&gt;&lt;div class="oucontent-saq-question"&gt;
&lt;p&gt;Calculate and print how many items were ordered, i.e. 5 in the example above. First change the algorithm, then translate it to code. Hint: you need to count the items in the list, their prices are irrelevant. If you get stuck, you can see the &lt;span class="oucontent-linkwithtip"&gt;&lt;a class="oucontent-hyperlink" href="https://trinket.io/python/aa5874c884"&gt;algorithm &lt;/a&gt;&lt;/span&gt;.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</dc:description><dc:publisher>The Open University</dc:publisher><dc:creator>The Open University</dc:creator><dc:type>Course</dc:type><dc:format>text/html</dc:format><dc:language>en-GB</dc:language><dc:source>Simple coding - SCOD_1</dc:source><cc:license>Copyright © 2015 The Open University</cc:license></item>
    <item>
      <title>5 Functions</title>
      <link>https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-5</link>
      <pubDate>Wed, 05 Dec 2018 12:40:26 GMT</pubDate>
      <description>&lt;p&gt;In this section you will learn about functions in the Python programming language.&amp;#xA0;&lt;/p&gt;&lt;p&gt;Totting up the bill is basically calculating the sum of a list of numbers. This is such a common need that Python already provides a&amp;#xA0;&lt;b&gt;function&lt;/b&gt;&amp;#xA0;for that, appropriately called&amp;#xA0;&lt;span class="oucontent-computercode"&gt;sum&lt;/span&gt;. A function takes some data (the function’s input) and returns some other data (the function’s output). In this case, the&amp;#xA0;&lt;span class="oucontent-computercode"&gt;sum&lt;/span&gt;&amp;#xA0;function takes a list of numbers as input and returns a single number as output.&lt;/p&gt;&lt;p&gt;To apply a function to some data (whether it’s a variable, a number or a string), just write the name of the function followed by the data in parenthesis. The computer will calculate the function’s output, which can be used in further calculations or assigned to a variable.&lt;/p&gt;&lt;div id="da33" class="oucontent-media oucontent-media-mini"&gt;&lt;div class="oucontent-figure-text"&gt;&lt;div class="oucontent-thumbnaillink oucontent-viewonlineactivity"&gt;&lt;a href="https://www.open.edu/openlearn/mod/oucontent/view.php?id=82140&amp;amp;extra=thumbnail_idm217"&gt;&lt;img src="https://www.open.edu/openlearn/pluginfile.php/1316320/mod_oucontent/oucontent/67640/3e81c503/018e27d9/iframe1.jpg" alt=""/&gt;&lt;br/&gt;View interactive version&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-caption oucontent-nonumber oucontent-caption-placeholder"&gt;&amp;#xA0;&lt;/div&gt;&lt;/div&gt;&lt;a id="back_thumbnail_idm217"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-interaction-print"&gt;&lt;div class="oucontent-interaction-unavailable"&gt;Interactive feature not available in single page view (&lt;a class="oucontent-crossref" href="https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-5#da33"&gt;see it in standard view&lt;/a&gt;).&lt;/div&gt;&lt;/div&gt;&lt;p&gt;As you can see, using the&amp;#xA0;&lt;span class="oucontent-computercode"&gt;sum&lt;/span&gt;&amp;#xA0;function shortens our code and makes it easier to understand, because the function’s name explicitly states what the code is doing. Good programmers don’t just write code, they write&amp;#xA0;&lt;i&gt;readable&lt;/i&gt;&amp;#xA0;code. They know that code always changes to accommodate further customer requests, and trying to modify cryptic code you wrote some weeks or months ago is no fun. Using comments and descriptive names for variables and functions helps making code readable.&lt;/p&gt;&lt;div class="oucontent-internalsection"&gt;
&lt;h2 class="oucontent-h2 oucontent-internalsection-head"&gt;The length function&lt;/h2&gt;
&lt;p&gt;Counting the number of items in a list is also so common, that Python has a function for that too, called&amp;#xA0;&lt;span class="oucontent-computercode"&gt;len&lt;/span&gt;, which returns the length of the list.&lt;/p&gt;
&lt;p&gt;Change the code above to show the number of ordered items, using the&amp;#xA0;&lt;span class="oucontent-computercode"&gt;len&lt;/span&gt;&amp;#xA0;function.&lt;/p&gt;
&lt;/div&gt;</description>
      <guid isPermaLink="true">https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-5</guid>
    <dc:title>5 Functions</dc:title><dc:identifier>SCOD_1</dc:identifier><dc:description>&lt;p&gt;In this section you will learn about functions in the Python programming language. &lt;/p&gt;&lt;p&gt;Totting up the bill is basically calculating the sum of a list of numbers. This is such a common need that Python already provides a &lt;b&gt;function&lt;/b&gt; for that, appropriately called &lt;span class="oucontent-computercode"&gt;sum&lt;/span&gt;. A function takes some data (the function’s input) and returns some other data (the function’s output). In this case, the &lt;span class="oucontent-computercode"&gt;sum&lt;/span&gt; function takes a list of numbers as input and returns a single number as output.&lt;/p&gt;&lt;p&gt;To apply a function to some data (whether it’s a variable, a number or a string), just write the name of the function followed by the data in parenthesis. The computer will calculate the function’s output, which can be used in further calculations or assigned to a variable.&lt;/p&gt;&lt;div id="da33" class="oucontent-media oucontent-media-mini"&gt;&lt;div class="oucontent-figure-text"&gt;&lt;div class="oucontent-thumbnaillink oucontent-viewonlineactivity"&gt;&lt;a href="https://www.open.edu/openlearn/mod/oucontent/view.php?id=82140&amp;extra=thumbnail_idm217"&gt;&lt;img src="https://www.open.edu/openlearn/pluginfile.php/1316320/mod_oucontent/oucontent/67640/3e81c503/018e27d9/iframe1.jpg" alt=""/&gt;&lt;br/&gt;View interactive version&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-caption oucontent-nonumber oucontent-caption-placeholder"&gt; &lt;/div&gt;&lt;/div&gt;&lt;a id="back_thumbnail_idm217"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-interaction-print"&gt;&lt;div class="oucontent-interaction-unavailable"&gt;Interactive feature not available in single page view (&lt;a class="oucontent-crossref" href="https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-5#da33"&gt;see it in standard view&lt;/a&gt;).&lt;/div&gt;&lt;/div&gt;&lt;p&gt;As you can see, using the &lt;span class="oucontent-computercode"&gt;sum&lt;/span&gt; function shortens our code and makes it easier to understand, because the function’s name explicitly states what the code is doing. Good programmers don’t just write code, they write &lt;i&gt;readable&lt;/i&gt; code. They know that code always changes to accommodate further customer requests, and trying to modify cryptic code you wrote some weeks or months ago is no fun. Using comments and descriptive names for variables and functions helps making code readable.&lt;/p&gt;&lt;div class="oucontent-internalsection"&gt;
&lt;h2 class="oucontent-h2 oucontent-internalsection-head"&gt;The length function&lt;/h2&gt;
&lt;p&gt;Counting the number of items in a list is also so common, that Python has a function for that too, called &lt;span class="oucontent-computercode"&gt;len&lt;/span&gt;, which returns the length of the list.&lt;/p&gt;
&lt;p&gt;Change the code above to show the number of ordered items, using the &lt;span class="oucontent-computercode"&gt;len&lt;/span&gt; function.&lt;/p&gt;
&lt;/div&gt;</dc:description><dc:publisher>The Open University</dc:publisher><dc:creator>The Open University</dc:creator><dc:type>Course</dc:type><dc:format>text/html</dc:format><dc:language>en-GB</dc:language><dc:source>Simple coding - SCOD_1</dc:source><cc:license>Copyright © 2015 The Open University</cc:license></item>
    <item>
      <title>5.1 The input function</title>
      <link>https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-5.1</link>
      <pubDate>Wed, 05 Dec 2018 12:40:26 GMT</pubDate>
      <description>&lt;p&gt;Another very useful function is&amp;#xA0;&lt;span class="oucontent-computercode"&gt;input&lt;/span&gt;: it takes a string that it prints on the screen (the user’s prompt), and returns a string with what the user typed on the keyboard until they pressed the RETURN or ENTER key. Run the code below and type in your name, followed by RETURN or ENTER.&lt;/p&gt;&lt;div id="po32" class="oucontent-media oucontent-media-mini"&gt;&lt;div class="oucontent-figure-text"&gt;&lt;div class="oucontent-thumbnaillink oucontent-viewonlineactivity"&gt;&lt;a href="https://www.open.edu/openlearn/mod/oucontent/view.php?id=82140&amp;amp;extra=thumbnail_idm233"&gt;&lt;img src="https://www.open.edu/openlearn/pluginfile.php/1316320/mod_oucontent/oucontent/67640/3e81c503/018e27d9/iframe1.jpg" alt=""/&gt;&lt;br/&gt;View interactive version&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-caption oucontent-nonumber oucontent-caption-placeholder"&gt;&amp;#xA0;&lt;/div&gt;&lt;/div&gt;&lt;a id="back_thumbnail_idm233"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-interaction-print"&gt;&lt;div class="oucontent-interaction-unavailable"&gt;Interactive feature not available in single page view (&lt;a class="oucontent-crossref" href="https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-5.1#po32"&gt;see it in standard view&lt;/a&gt;).&lt;/div&gt;&lt;/div&gt;&lt;p&gt;Note that&amp;#xA0;&lt;span class="oucontent-computercode"&gt;input&lt;/span&gt;&amp;#xA0;always returns a string, even if the user typed in a number. To see the implications of that, run the code below and type in your birth year.&lt;/p&gt;&lt;div id="hii78" class="oucontent-media oucontent-media-mini"&gt;&lt;div class="oucontent-figure-text"&gt;&lt;div class="oucontent-thumbnaillink oucontent-viewonlineactivity"&gt;&lt;a href="https://www.open.edu/openlearn/mod/oucontent/view.php?id=82140&amp;amp;extra=thumbnail_idm238"&gt;&lt;img src="https://www.open.edu/openlearn/pluginfile.php/1316320/mod_oucontent/oucontent/67640/3e81c503/018e27d9/iframe1.jpg" alt=""/&gt;&lt;br/&gt;View interactive version&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-caption oucontent-nonumber oucontent-caption-placeholder"&gt;&amp;#xA0;&lt;/div&gt;&lt;/div&gt;&lt;a id="back_thumbnail_idm238"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-interaction-print"&gt;&lt;div class="oucontent-interaction-unavailable"&gt;Interactive feature not available in single page view (&lt;a class="oucontent-crossref" href="https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-5.1#hii78"&gt;see it in standard view&lt;/a&gt;).&lt;/div&gt;&lt;/div&gt;&lt;p&gt;The computer reports a type error, because the code is mixing two different types of data. It is trying to subtract the string returned by&amp;#xA0;&lt;span class="oucontent-computercode"&gt;input&lt;/span&gt;&amp;#xA0;from the number&amp;#xA0;2015.&lt;/p&gt;</description>
      <guid isPermaLink="true">https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-5.1</guid>
    <dc:title>5.1 The input function</dc:title><dc:identifier>SCOD_1</dc:identifier><dc:description>&lt;p&gt;Another very useful function is &lt;span class="oucontent-computercode"&gt;input&lt;/span&gt;: it takes a string that it prints on the screen (the user’s prompt), and returns a string with what the user typed on the keyboard until they pressed the RETURN or ENTER key. Run the code below and type in your name, followed by RETURN or ENTER.&lt;/p&gt;&lt;div id="po32" class="oucontent-media oucontent-media-mini"&gt;&lt;div class="oucontent-figure-text"&gt;&lt;div class="oucontent-thumbnaillink oucontent-viewonlineactivity"&gt;&lt;a href="https://www.open.edu/openlearn/mod/oucontent/view.php?id=82140&amp;extra=thumbnail_idm233"&gt;&lt;img src="https://www.open.edu/openlearn/pluginfile.php/1316320/mod_oucontent/oucontent/67640/3e81c503/018e27d9/iframe1.jpg" alt=""/&gt;&lt;br/&gt;View interactive version&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-caption oucontent-nonumber oucontent-caption-placeholder"&gt; &lt;/div&gt;&lt;/div&gt;&lt;a id="back_thumbnail_idm233"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-interaction-print"&gt;&lt;div class="oucontent-interaction-unavailable"&gt;Interactive feature not available in single page view (&lt;a class="oucontent-crossref" href="https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-5.1#po32"&gt;see it in standard view&lt;/a&gt;).&lt;/div&gt;&lt;/div&gt;&lt;p&gt;Note that &lt;span class="oucontent-computercode"&gt;input&lt;/span&gt; always returns a string, even if the user typed in a number. To see the implications of that, run the code below and type in your birth year.&lt;/p&gt;&lt;div id="hii78" class="oucontent-media oucontent-media-mini"&gt;&lt;div class="oucontent-figure-text"&gt;&lt;div class="oucontent-thumbnaillink oucontent-viewonlineactivity"&gt;&lt;a href="https://www.open.edu/openlearn/mod/oucontent/view.php?id=82140&amp;extra=thumbnail_idm238"&gt;&lt;img src="https://www.open.edu/openlearn/pluginfile.php/1316320/mod_oucontent/oucontent/67640/3e81c503/018e27d9/iframe1.jpg" alt=""/&gt;&lt;br/&gt;View interactive version&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-caption oucontent-nonumber oucontent-caption-placeholder"&gt; &lt;/div&gt;&lt;/div&gt;&lt;a id="back_thumbnail_idm238"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-interaction-print"&gt;&lt;div class="oucontent-interaction-unavailable"&gt;Interactive feature not available in single page view (&lt;a class="oucontent-crossref" href="https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-5.1#hii78"&gt;see it in standard view&lt;/a&gt;).&lt;/div&gt;&lt;/div&gt;&lt;p&gt;The computer reports a type error, because the code is mixing two different types of data. It is trying to subtract the string returned by &lt;span class="oucontent-computercode"&gt;input&lt;/span&gt; from the number 2015.&lt;/p&gt;</dc:description><dc:publisher>The Open University</dc:publisher><dc:creator>The Open University</dc:creator><dc:type>Course</dc:type><dc:format>text/html</dc:format><dc:language>en-GB</dc:language><dc:source>Simple coding - SCOD_1</dc:source><cc:license>Copyright © 2015 The Open University</cc:license></item>
    <item>
      <title>5.2 A conversion function</title>
      <link>https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-5.2</link>
      <pubDate>Wed, 05 Dec 2018 12:40:26 GMT</pubDate>
      <description>&lt;p&gt;The solution is to use the built-in function&amp;#xA0;&lt;span class="oucontent-computercode"&gt;int&lt;/span&gt;&amp;#xA0;that takes a string and converts it to an&amp;#xA0;&lt;b&gt;integer&lt;/b&gt;, which is a number like –2, –1, 0, 1, 2, etc. If the string represents a decimal number,&amp;#xA0;&lt;span class="oucontent-computercode"&gt;int&lt;/span&gt;&amp;#xA0;will give an error.&lt;/p&gt;&lt;div id="su32" class="oucontent-media oucontent-media-mini"&gt;&lt;div class="oucontent-figure-text"&gt;&lt;div class="oucontent-thumbnaillink oucontent-viewonlineactivity"&gt;&lt;a href="https://www.open.edu/openlearn/mod/oucontent/view.php?id=82140&amp;amp;extra=thumbnail_idm249"&gt;&lt;img src="https://www.open.edu/openlearn/pluginfile.php/1316320/mod_oucontent/oucontent/67640/3e81c503/018e27d9/iframe1.jpg" alt=""/&gt;&lt;br/&gt;View interactive version&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-caption oucontent-nonumber oucontent-caption-placeholder"&gt;&amp;#xA0;&lt;/div&gt;&lt;/div&gt;&lt;a id="back_thumbnail_idm249"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-interaction-print"&gt;&lt;div class="oucontent-interaction-unavailable"&gt;Interactive feature not available in single page view (&lt;a class="oucontent-crossref" href="https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-5.2#su32"&gt;see it in standard view&lt;/a&gt;).&lt;/div&gt;&lt;/div&gt;&lt;div class="&amp;#10;            oucontent-activity&amp;#10;           oucontent-s-heavybox1 oucontent-s-box "&gt;&lt;div class="oucontent-outer-box"&gt;&lt;h2 class="oucontent-h3 oucontent-heading oucontent-nonumber"&gt;Activity 8&lt;/h2&gt;&lt;div class="oucontent-inner-box"&gt;&lt;div class="oucontent-saq-question"&gt;
&lt;p&gt;Change the restaurant program (repeated below) so that it asks the user for the number of people.&lt;/p&gt;
&lt;div id="zv3" class="oucontent-media oucontent-media-mini"&gt;&lt;div class="oucontent-figure-text"&gt;&lt;div class="oucontent-thumbnaillink oucontent-viewonlineactivity"&gt;&lt;a href="https://www.open.edu/openlearn/mod/oucontent/view.php?id=82140&amp;amp;extra=thumbnail_idm256"&gt;&lt;img src="https://www.open.edu/openlearn/pluginfile.php/1316320/mod_oucontent/oucontent/67640/3e81c503/018e27d9/iframe1.jpg" alt=""/&gt;&lt;br/&gt;View interactive version&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-caption oucontent-nonumber oucontent-caption-placeholder"&gt;&amp;#xA0;&lt;/div&gt;&lt;/div&gt;&lt;a id="back_thumbnail_idm256"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-interaction-print"&gt;&lt;div class="oucontent-interaction-unavailable"&gt;Interactive feature not available in single page view (&lt;a class="oucontent-crossref" href="https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-5.2#zv3"&gt;see it in standard view&lt;/a&gt;).&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;Next, in Section 6, you’ll learn a different form of iteration.&lt;/p&gt;</description>
      <guid isPermaLink="true">https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-5.2</guid>
    <dc:title>5.2 A conversion function</dc:title><dc:identifier>SCOD_1</dc:identifier><dc:description>&lt;p&gt;The solution is to use the built-in function &lt;span class="oucontent-computercode"&gt;int&lt;/span&gt; that takes a string and converts it to an &lt;b&gt;integer&lt;/b&gt;, which is a number like –2, –1, 0, 1, 2, etc. If the string represents a decimal number, &lt;span class="oucontent-computercode"&gt;int&lt;/span&gt; will give an error.&lt;/p&gt;&lt;div id="su32" class="oucontent-media oucontent-media-mini"&gt;&lt;div class="oucontent-figure-text"&gt;&lt;div class="oucontent-thumbnaillink oucontent-viewonlineactivity"&gt;&lt;a href="https://www.open.edu/openlearn/mod/oucontent/view.php?id=82140&amp;extra=thumbnail_idm249"&gt;&lt;img src="https://www.open.edu/openlearn/pluginfile.php/1316320/mod_oucontent/oucontent/67640/3e81c503/018e27d9/iframe1.jpg" alt=""/&gt;&lt;br/&gt;View interactive version&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-caption oucontent-nonumber oucontent-caption-placeholder"&gt; &lt;/div&gt;&lt;/div&gt;&lt;a id="back_thumbnail_idm249"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-interaction-print"&gt;&lt;div class="oucontent-interaction-unavailable"&gt;Interactive feature not available in single page view (&lt;a class="oucontent-crossref" href="https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-5.2#su32"&gt;see it in standard view&lt;/a&gt;).&lt;/div&gt;&lt;/div&gt;&lt;div class="
            oucontent-activity
           oucontent-s-heavybox1 oucontent-s-box "&gt;&lt;div class="oucontent-outer-box"&gt;&lt;h2 class="oucontent-h3 oucontent-heading oucontent-nonumber"&gt;Activity 8&lt;/h2&gt;&lt;div class="oucontent-inner-box"&gt;&lt;div class="oucontent-saq-question"&gt;
&lt;p&gt;Change the restaurant program (repeated below) so that it asks the user for the number of people.&lt;/p&gt;
&lt;div id="zv3" class="oucontent-media oucontent-media-mini"&gt;&lt;div class="oucontent-figure-text"&gt;&lt;div class="oucontent-thumbnaillink oucontent-viewonlineactivity"&gt;&lt;a href="https://www.open.edu/openlearn/mod/oucontent/view.php?id=82140&amp;extra=thumbnail_idm256"&gt;&lt;img src="https://www.open.edu/openlearn/pluginfile.php/1316320/mod_oucontent/oucontent/67640/3e81c503/018e27d9/iframe1.jpg" alt=""/&gt;&lt;br/&gt;View interactive version&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-caption oucontent-nonumber oucontent-caption-placeholder"&gt; &lt;/div&gt;&lt;/div&gt;&lt;a id="back_thumbnail_idm256"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-interaction-print"&gt;&lt;div class="oucontent-interaction-unavailable"&gt;Interactive feature not available in single page view (&lt;a class="oucontent-crossref" href="https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-5.2#zv3"&gt;see it in standard view&lt;/a&gt;).&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;Next, in Section 6, you’ll learn a different form of iteration.&lt;/p&gt;</dc:description><dc:publisher>The Open University</dc:publisher><dc:creator>The Open University</dc:creator><dc:type>Course</dc:type><dc:format>text/html</dc:format><dc:language>en-GB</dc:language><dc:source>Simple coding - SCOD_1</dc:source><cc:license>Copyright © 2015 The Open University</cc:license></item>
    <item>
      <title>6 Iteration (part 2)</title>
      <link>https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-6</link>
      <pubDate>Wed, 05 Dec 2018 12:40:26 GMT</pubDate>
      <description>&lt;p&gt;In this section you will learn more about iteration and repetition in the Python programming language.&amp;#xA0;&lt;/p&gt;&lt;p&gt;Let’s use&amp;#xA0;input&amp;#xA0;to ask for the price of orders instead of fixing them in a list. This requires a new iteration: an infinite loop that keeps asking until the user types &amp;#x2018;stop’, for example. We also need to convert the string returned by&amp;#xA0;input&amp;#xA0;into a number we can add to the expenses. The algorithm is:&lt;/p&gt;&lt;ol class="oucontent-numbered"&gt;&lt;li&gt;let the expenses be zero&lt;/li&gt;&lt;li&gt;forever repeat the following:&lt;ol class="oucontent-numbered"&gt;&lt;li&gt;let answer be the reply to the question &amp;#x201C;Price of ordered item?&amp;#x201D;&lt;/li&gt;&lt;li&gt;if the answer is equal to &amp;#x201C;stop&amp;#x201D;:&lt;/li&gt;&lt;/ol&gt;&lt;ul class="oucontent-unnumbered"&gt;&lt;li&gt;exit the loop&lt;/li&gt;&lt;/ul&gt;&lt;ol class="oucontent-numbered" start="3"&gt;&lt;li&gt;otherwise:&lt;/li&gt;&lt;/ol&gt;&lt;ul class="oucontent-numbered"&gt;&lt;li class="oucontent-markerdirect"&gt;&lt;span class="oucontent-listmarker"&gt;i.&lt;/span&gt;let the price be the answer converted to a decimal number&lt;/li&gt;&lt;li class="oucontent-markerdirect"&gt;&lt;span class="oucontent-listmarker"&gt;ii.&lt;/span&gt;add the price to the expenses&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Test the code below: provide the same values as before (4.35, 2, 19.95, 22.70 and 5), followed by&amp;#xA0;stop,&amp;#xA0;and check the sum is at the end 54.&lt;/p&gt;&lt;div id="dsd3" class="oucontent-media oucontent-media-mini"&gt;&lt;div class="oucontent-figure-text"&gt;&lt;div class="oucontent-thumbnaillink oucontent-viewonlineactivity"&gt;&lt;a href="https://www.open.edu/openlearn/mod/oucontent/view.php?id=82140&amp;amp;extra=thumbnail_idm278"&gt;&lt;img src="https://www.open.edu/openlearn/pluginfile.php/1316320/mod_oucontent/oucontent/67640/3e81c503/018e27d9/iframe1.jpg" alt=""/&gt;&lt;br/&gt;View interactive version&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-caption oucontent-nonumber oucontent-caption-placeholder"&gt;&amp;#xA0;&lt;/div&gt;&lt;/div&gt;&lt;a id="back_thumbnail_idm278"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-interaction-print"&gt;&lt;div class="oucontent-interaction-unavailable"&gt;Interactive feature not available in single page view (&lt;a class="oucontent-crossref" href="https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-6#dsd3"&gt;see it in standard view&lt;/a&gt;).&lt;/div&gt;&lt;/div&gt;&lt;p&gt;In Python, the &amp;#x2018;while&amp;#xA0;condition:&amp;#xA0;block’ instruction keeps executing the block while the condition is true. In this case the condition is always&amp;#xA0;True&amp;#xA0;(note the initial uppercase), which leads to an infinite loop. Doing forever the same thing can get a bit tedious, so at some point I have to break free with the appropriately named&amp;#xA0;break&amp;#xA0;instruction. At that point the computer starts executing whatever code follows the loop.&lt;/p&gt;&lt;p&gt;Note that food and drink prices may be in pence or cents, so I need to convert the user’s input string to a decimal number (called a&amp;#xA0;&lt;b&gt;floating point&lt;/b&gt;&amp;#xA0;number in Python), using the function&amp;#xA0;&lt;span class="oucontent-computercode"&gt;float&lt;/span&gt;&amp;#xA0;instead of&amp;#xA0;&lt;span class="oucontent-computercode"&gt;int&lt;/span&gt;.&lt;/p&gt;&lt;p&gt;Note also that to check if two values or variables are equal, we write two equal signs, because a single equal sign is the assignment instruction.&lt;/p&gt;&lt;div class="&amp;#10;            oucontent-activity&amp;#10;           oucontent-s-heavybox1 oucontent-s-box "&gt;&lt;div class="oucontent-outer-box"&gt;&lt;h2 class="oucontent-h3 oucontent-heading oucontent-nonumber"&gt;Activity 9&lt;/h2&gt;&lt;div class="oucontent-inner-box"&gt;&lt;div class="oucontent-saq-question"&gt;
&lt;p&gt;Put a complete program together, that starts as above, then asks the user for the number of people in the group, computes the tip and the VAT (20% on the expenses) and finally prints the total bill.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
      <guid isPermaLink="true">https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-6</guid>
    <dc:title>6 Iteration (part 2)</dc:title><dc:identifier>SCOD_1</dc:identifier><dc:description>&lt;p&gt;In this section you will learn more about iteration and repetition in the Python programming language. &lt;/p&gt;&lt;p&gt;Let’s use input to ask for the price of orders instead of fixing them in a list. This requires a new iteration: an infinite loop that keeps asking until the user types ‘stop’, for example. We also need to convert the string returned by input into a number we can add to the expenses. The algorithm is:&lt;/p&gt;&lt;ol class="oucontent-numbered"&gt;&lt;li&gt;let the expenses be zero&lt;/li&gt;&lt;li&gt;forever repeat the following:&lt;ol class="oucontent-numbered"&gt;&lt;li&gt;let answer be the reply to the question “Price of ordered item?”&lt;/li&gt;&lt;li&gt;if the answer is equal to “stop”:&lt;/li&gt;&lt;/ol&gt;&lt;ul class="oucontent-unnumbered"&gt;&lt;li&gt;exit the loop&lt;/li&gt;&lt;/ul&gt;&lt;ol class="oucontent-numbered" start="3"&gt;&lt;li&gt;otherwise:&lt;/li&gt;&lt;/ol&gt;&lt;ul class="oucontent-numbered"&gt;&lt;li class="oucontent-markerdirect"&gt;&lt;span class="oucontent-listmarker"&gt;i.&lt;/span&gt;let the price be the answer converted to a decimal number&lt;/li&gt;&lt;li class="oucontent-markerdirect"&gt;&lt;span class="oucontent-listmarker"&gt;ii.&lt;/span&gt;add the price to the expenses&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Test the code below: provide the same values as before (4.35, 2, 19.95, 22.70 and 5), followed by stop, and check the sum is at the end 54.&lt;/p&gt;&lt;div id="dsd3" class="oucontent-media oucontent-media-mini"&gt;&lt;div class="oucontent-figure-text"&gt;&lt;div class="oucontent-thumbnaillink oucontent-viewonlineactivity"&gt;&lt;a href="https://www.open.edu/openlearn/mod/oucontent/view.php?id=82140&amp;extra=thumbnail_idm278"&gt;&lt;img src="https://www.open.edu/openlearn/pluginfile.php/1316320/mod_oucontent/oucontent/67640/3e81c503/018e27d9/iframe1.jpg" alt=""/&gt;&lt;br/&gt;View interactive version&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-caption oucontent-nonumber oucontent-caption-placeholder"&gt; &lt;/div&gt;&lt;/div&gt;&lt;a id="back_thumbnail_idm278"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-interaction-print"&gt;&lt;div class="oucontent-interaction-unavailable"&gt;Interactive feature not available in single page view (&lt;a class="oucontent-crossref" href="https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-6#dsd3"&gt;see it in standard view&lt;/a&gt;).&lt;/div&gt;&lt;/div&gt;&lt;p&gt;In Python, the ‘while condition: block’ instruction keeps executing the block while the condition is true. In this case the condition is always True (note the initial uppercase), which leads to an infinite loop. Doing forever the same thing can get a bit tedious, so at some point I have to break free with the appropriately named break instruction. At that point the computer starts executing whatever code follows the loop.&lt;/p&gt;&lt;p&gt;Note that food and drink prices may be in pence or cents, so I need to convert the user’s input string to a decimal number (called a &lt;b&gt;floating point&lt;/b&gt; number in Python), using the function &lt;span class="oucontent-computercode"&gt;float&lt;/span&gt; instead of &lt;span class="oucontent-computercode"&gt;int&lt;/span&gt;.&lt;/p&gt;&lt;p&gt;Note also that to check if two values or variables are equal, we write two equal signs, because a single equal sign is the assignment instruction.&lt;/p&gt;&lt;div class="
            oucontent-activity
           oucontent-s-heavybox1 oucontent-s-box "&gt;&lt;div class="oucontent-outer-box"&gt;&lt;h2 class="oucontent-h3 oucontent-heading oucontent-nonumber"&gt;Activity 9&lt;/h2&gt;&lt;div class="oucontent-inner-box"&gt;&lt;div class="oucontent-saq-question"&gt;
&lt;p&gt;Put a complete program together, that starts as above, then asks the user for the number of people in the group, computes the tip and the VAT (20% on the expenses) and finally prints the total bill.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</dc:description><dc:publisher>The Open University</dc:publisher><dc:creator>The Open University</dc:creator><dc:type>Course</dc:type><dc:format>text/html</dc:format><dc:language>en-GB</dc:language><dc:source>Simple coding - SCOD_1</dc:source><cc:license>Copyright © 2015 The Open University</cc:license></item>
    <item>
      <title>6.1 The oldest algorithm</title>
      <link>https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-6.1</link>
      <pubDate>Wed, 05 Dec 2018 12:40:26 GMT</pubDate>
      <description>&lt;p&gt;The&amp;#xA0;while&amp;#xA0;loop condition doesn’t have to be always true, of course. As an example, here is one of the oldest algorithms known, Euclid’s algorithm, used to find the greatest common divisor of two integers greater than zero, i.e. the greatest number that divides both without any remainder. For example, the greatest common divisor of 3 and 7 is 1, and of 21 and 49 is 7. This is needed to simplify fractions, for example. Explaining the maths that make&amp;#xA0;the algorithm work is beyond the scope of this tutorial.&lt;/p&gt;&lt;div class="&amp;#10;            oucontent-activity&amp;#10;           oucontent-s-heavybox1 oucontent-s-box "&gt;&lt;div class="oucontent-outer-box"&gt;&lt;h2 class="oucontent-h3 oucontent-heading oucontent-nonumber"&gt;Activity 10&lt;/h2&gt;&lt;div class="oucontent-inner-box"&gt;&lt;div class="oucontent-saq-question"&gt;
&lt;p&gt;Translate the algorithm below to Python. One instruction was already translated for you. Don’t forget to test your code.&lt;/p&gt;
&lt;div id="atr3" class="oucontent-media oucontent-media-mini"&gt;&lt;div class="oucontent-figure-text"&gt;&lt;div class="oucontent-thumbnaillink oucontent-viewonlineactivity"&gt;&lt;a href="https://www.open.edu/openlearn/mod/oucontent/view.php?id=82140&amp;amp;extra=thumbnail_idm298"&gt;View interactive version&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-caption oucontent-nonumber oucontent-caption-placeholder"&gt;&amp;#xA0;&lt;/div&gt;&lt;/div&gt;&lt;a id="back_thumbnail_idm298"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-interaction-print"&gt;&lt;div class="oucontent-interaction-unavailable"&gt;Interactive feature not available in single page view (&lt;a class="oucontent-crossref" href="https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-6.1#atr3"&gt;see it in standard view&lt;/a&gt;).&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;Note that for the loop to end, the condition must become false, i.e. both variables&amp;#xA0;n&amp;#xA0;and&amp;#xA0;m&amp;#xA0;have the same value. Therefore it doesn’t matter which one you print.&lt;/p&gt;</description>
      <guid isPermaLink="true">https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-6.1</guid>
    <dc:title>6.1 The oldest algorithm</dc:title><dc:identifier>SCOD_1</dc:identifier><dc:description>&lt;p&gt;The while loop condition doesn’t have to be always true, of course. As an example, here is one of the oldest algorithms known, Euclid’s algorithm, used to find the greatest common divisor of two integers greater than zero, i.e. the greatest number that divides both without any remainder. For example, the greatest common divisor of 3 and 7 is 1, and of 21 and 49 is 7. This is needed to simplify fractions, for example. Explaining the maths that make the algorithm work is beyond the scope of this tutorial.&lt;/p&gt;&lt;div class="
            oucontent-activity
           oucontent-s-heavybox1 oucontent-s-box "&gt;&lt;div class="oucontent-outer-box"&gt;&lt;h2 class="oucontent-h3 oucontent-heading oucontent-nonumber"&gt;Activity 10&lt;/h2&gt;&lt;div class="oucontent-inner-box"&gt;&lt;div class="oucontent-saq-question"&gt;
&lt;p&gt;Translate the algorithm below to Python. One instruction was already translated for you. Don’t forget to test your code.&lt;/p&gt;
&lt;div id="atr3" class="oucontent-media oucontent-media-mini"&gt;&lt;div class="oucontent-figure-text"&gt;&lt;div class="oucontent-thumbnaillink oucontent-viewonlineactivity"&gt;&lt;a href="https://www.open.edu/openlearn/mod/oucontent/view.php?id=82140&amp;extra=thumbnail_idm298"&gt;View interactive version&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-caption oucontent-nonumber oucontent-caption-placeholder"&gt; &lt;/div&gt;&lt;/div&gt;&lt;a id="back_thumbnail_idm298"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="oucontent-interaction-print"&gt;&lt;div class="oucontent-interaction-unavailable"&gt;Interactive feature not available in single page view (&lt;a class="oucontent-crossref" href="https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-6.1#atr3"&gt;see it in standard view&lt;/a&gt;).&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;Note that for the loop to end, the condition must become false, i.e. both variables n and m have the same value. Therefore it doesn’t matter which one you print.&lt;/p&gt;</dc:description><dc:publisher>The Open University</dc:publisher><dc:creator>The Open University</dc:creator><dc:type>Course</dc:type><dc:format>text/html</dc:format><dc:language>en-GB</dc:language><dc:source>Simple coding - SCOD_1</dc:source><cc:license>Copyright © 2015 The Open University</cc:license></item>
    <item>
      <title>Summary</title>
      <link>https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-7</link>
      <pubDate>Wed, 05 Dec 2018 12:40:26 GMT</pubDate>
      <description>&lt;p&gt;In this brief introduction to programming you have seen the fundamental building blocks that almost every programming language provides:&lt;/p&gt;&lt;ul class="oucontent-bulleted"&gt;&lt;li&gt;variables and assignment (=) to store and update data&lt;/li&gt;&lt;li&gt;arithmetic operators (+,&amp;#xA0;-,&amp;#xA0;*)&lt;/li&gt;&lt;li&gt;simple data types (strings and numbers, both integers and floating point)&lt;/li&gt;&lt;li&gt;data structures (lists)&lt;/li&gt;&lt;li&gt;sequence (one instruction per line)&lt;/li&gt;&lt;li&gt;iteration (for&amp;#xA0;and&amp;#xA0;while&amp;#xA0;loops)&lt;/li&gt;&lt;li&gt;selection (if-else&amp;#xA0;and&amp;#xA0;if-elif-elif-...-else),&lt;/li&gt;&lt;li&gt;comparisons (&amp;gt;,&amp;#xA0;&amp;lt;,&amp;#xA0;==,&amp;#xA0;!=,&amp;#xA0;&amp;gt;=,&amp;#xA0;&amp;lt;=)&lt;/li&gt;&lt;li&gt;functions (len&amp;#xA0;and&amp;#xA0;sum&amp;#xA0;for lists,&amp;#xA0;int&amp;#xA0;and&amp;#xA0;float&amp;#xA0;to convert strings to numbers)&lt;/li&gt;&lt;li&gt;input from the keyboard (input&amp;#xA0;function)&lt;/li&gt;&lt;li&gt;output to the screen (print&amp;#xA0;instruction)&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Programming languages have to be automatically understood by a machine, so the syntax and grammar are much more constrained than English and other natural languages. Any spelling mistake, like writing&amp;#xA0;flat&amp;#xA0;instead of&amp;#xA0;float&amp;#xA0;or forgetting punctuation like commas and colons, or using the wrong data type, leads to an error.&lt;/p&gt;&lt;p&gt;You have also seen that programming involves writing clear and understandable code (e.g. by using comments and plain English names for variables and functions) to make it easier to change later, and testing it thoroughly.&lt;/p&gt;&lt;p&gt;Learning to program forces us to think clearly and rigorously when solving a problem, because the solution has to be described in very small and precise steps that even a machine can understand. Python makes it easy to write the code once we come up with a sufficiently detailed algorithm, but the thinking (still) has to be done by us.&lt;/p&gt;&lt;p&gt;Like learning any other skill, only practice makes perfect. We hope this course inspired you to learn more Python and to share your creations with friends and family.&lt;/p&gt;</description>
      <guid isPermaLink="true">https://www.open.edu/openlearn/science-maths-technology/simple-coding/content-section-7</guid>
    <dc:title>Summary</dc:title><dc:identifier>SCOD_1</dc:identifier><dc:description>&lt;p&gt;In this brief introduction to programming you have seen the fundamental building blocks that almost every programming language provides:&lt;/p&gt;&lt;ul class="oucontent-bulleted"&gt;&lt;li&gt;variables and assignment (=) to store and update data&lt;/li&gt;&lt;li&gt;arithmetic operators (+, -, *)&lt;/li&gt;&lt;li&gt;simple data types (strings and numbers, both integers and floating point)&lt;/li&gt;&lt;li&gt;data structures (lists)&lt;/li&gt;&lt;li&gt;sequence (one instruction per line)&lt;/li&gt;&lt;li&gt;iteration (for and while loops)&lt;/li&gt;&lt;li&gt;selection (if-else and if-elif-elif-...-else),&lt;/li&gt;&lt;li&gt;comparisons (&gt;, &lt;, ==, !=, &gt;=, &lt;=)&lt;/li&gt;&lt;li&gt;functions (len and sum for lists, int and float to convert strings to numbers)&lt;/li&gt;&lt;li&gt;input from the keyboard (input function)&lt;/li&gt;&lt;li&gt;output to the screen (print instruction)&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Programming languages have to be automatically understood by a machine, so the syntax and grammar are much more constrained than English and other natural languages. Any spelling mistake, like writing flat instead of float or forgetting punctuation like commas and colons, or using the wrong data type, leads to an error.&lt;/p&gt;&lt;p&gt;You have also seen that programming involves writing clear and understandable code (e.g. by using comments and plain English names for variables and functions) to make it easier to change later, and testing it thoroughly.&lt;/p&gt;&lt;p&gt;Learning to program forces us to think clearly and rigorously when solving a problem, because the solution has to be described in very small and precise steps that even a machine can understand. Python makes it easy to write the code once we come up with a sufficiently detailed algorithm, but the thinking (still) has to be done by us.&lt;/p&gt;&lt;p&gt;Like learning any other skill, only practice makes perfect. We hope this course inspired you to learn more Python and to share your creations with friends and family.&lt;/p&gt;</dc:description><dc:publisher>The Open University</dc:publisher><dc:creator>The Open University</dc:creator><dc:type>Course</dc:type><dc:format>text/html</dc:format><dc:language>en-GB</dc:language><dc:source>Simple coding - SCOD_1</dc:source><cc:license>Copyright © 2015 The Open University</cc:license></item>
  </channel>
</rss>
