<jupyter_start><jupyter_text>![Noteable.ac.uk Banner](https://github.com/jstix/mr-noteable/blob/master/Banner%20image/1500x500.jfif?raw=true)  Introduction to programming  Legend for colors     In  blue, the  instructions  and  goals  are highlighted.     In  green, the  information  is highlighted.     In  yellow, the  exercises  are highlighted.     In  red, the  error   and  alert messages  are highlighted.  Instructions    Click "Run" on each cell to go through the code in each cell. This will take you through the cell and print out the results.   If you wish to see all the outputs at once in the whole notebook, just click Cell and then Run All.   Goal After this workshop, the student should get more familiar with the following topics:       printing basic statements and commands in Jupyter Notebook     performing basic arithmetic calculations in Python     improving an existent model of the code     These objectives are in agreement with the National 3 Scottish Curriculum for high-school students.     Note:  For most of the workshop, the student will be given some coding examples. In some cases, the student will have to code himself/herself. The coding part is optional, but highly recommended to approach.     Explore  Some printing statements... Let us begin with a very simple exercise:<jupyter_code>print("Hello!! Welcome to your first programming workshop. I am here to help you")<jupyter_output><empty_output><jupyter_text>This is an example of what a computer does: given some  input , some data from the keyboard, it produces a specific output. In this case, the output is as simple as it gets. We just print out a statement, this is the main usage of print function.  Do not remove the "" sign when printing statments, otherwise the code will not work.    What happens if you remove the sign though?  Before the end of the next workshop, we will discuss this. However, for the moment, let us do some practice.   Exercise:  Investigate the following code:<jupyter_code>input("Put in your name: ")<jupyter_output><empty_output><jupyter_text>What happens when you type in the above command? Discuss this in pairs if you find it more helpful.   Exercise:  Modify the above line to the following - "Put in your whole name" and type the name accordingly.<jupyter_code># Type your whole name using the input function here<jupyter_output><empty_output><jupyter_text>Let us try now another small code together: we will print, at a very basic level, a Tic-Tac-Toe board.<jupyter_code>print("x" "o" "o")
print("o" "o" "x")
print("x" "o" "x")<jupyter_output><empty_output><jupyter_text>We have just printed out what was supposed to be the design of a tic tac toe!   Exercise:  Can you print out a similar design for tic-tac-toe, but with four lines and four columns?<jupyter_code># Try printing a 4-by-4 Tic Tac Toe board<jupyter_output><empty_output><jupyter_text>You can also use your creativity to create whatever you want (tree, smiley face, go for it). Let us try one more example together<jupyter_code>print(" . " " o " " . " " o " " . ")
print(" . " " . " " | " " . " " . ")
print(" o " " . " " . " " . " " o ")
print(" . " " o " " o " " o " " . ")
print(" . " " . " " . " " . " " . ")<jupyter_output>.  o  .  o  . 
 .  .  |  .  . 
 o  .  .  .  o 
 .  o  o  o  . 
 .  .  .  .  .<jupyter_text>This is how a smiley face can look! Of course, examples are plenty so try more to make it better!  Exercise:  For example, can you add to this smiley face a beard? Use this as hint if you find it too hard: add a v-character under the middle circle. Talk about it in pairs, suggest improvements to the sketch above, try drawing everything on a paper before doing it on your notebook.    Question:  Did I proceed well by keeping the dots? What if I remove them? First think it through your head, then do the adjustments:    Note:  There is no correct answer, this is up to your imagination.<jupyter_code># Draw your new smiley face here<jupyter_output><empty_output><jupyter_text>And some arithmetic operations Let us see how the computer plays with numbers as well<jupyter_code>print(2+3)<jupyter_output><empty_output><jupyter_text>Alright, so the computer does know how to play with numbers! Let us try with bigger ones<jupyter_code>print(89275*4354)
print(552643/324)<jupyter_output><empty_output><jupyter_text>How to raise a number to the power of another number?<jupyter_code>2**5<jupyter_output><empty_output><jupyter_text>Exercise:  Compute the following operation: $ 3^{4} + \frac{21}{35} + (4 \cdot 4) $<jupyter_code># Perform the arithmetic operation here:<jupyter_output><empty_output><jupyter_text>Notice how print is the command line for showing us what the computer has done. This is what we call  output.  For Jupyter Notebooks, however, you do not even need to use this command. Let us try one more command:<jupyter_code>print(3<5)<jupyter_output><empty_output><jupyter_text>So we can also do comparisons between different numbers<jupyter_code>print(4>5)<jupyter_output><empty_output><jupyter_text>Take-away This is it for today, and well done for managing to go through the material!!   After this session, you should be more familiar with how simple sentences, numbers and conditional statements can be printed in Python. Also, feel free to work more on this notebook using any commands you would like.   Note:  Always keep a back-up of the notebook, in case the original one is altered.  For today's session, this should be enough! See you later!!<jupyter_code>print("Bye bye! :D")<jupyter_output><empty_output>