You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<li>An introduction to Python, and how to get started with this course.</li>
34
34
</ul>
35
35
<p>Modern programming is practically always done in an IDE (integrated development environment). An IDE contains a set of useful tools for the programmer. It does not create the program by itself, but it can give hints about common mistakes in the code, and help the programmer understand the structure of the program.</p>
<p>The above statement is pre-built into Python, and it's used for printing a string. The statement tells the computer to output the string that's been provided to it, placed between the quotation marks.</p>
60
-
<p>A lot of the programs you'll see in this course will have a certain frame around the code; the <code>def main():</code> syntax and the <code>if __name__ == '__main__':</code> block. Don't worry too much about this for now, it'll become very familiar over the course of the material. You don't technically need the framing around the <code>print</code> statement or the <code>if __name__ == '__main__':</code> block for the program to be able to run in Python, but it's useful to get into the habit now to make things easier later.</p>
60
+
<p>A lot of the programs you'll see in this course will have a certain frame around the code; the <code>def main():</code> syntax and the <code>if __name__ == '__main__':</code> block. Don't worry too much about this for now, it'll become very familiar over the course of the material. You don't technically need the framing around the <code>print</code> statement or the <code>if __name__ == '__main__':</code> block for the program to be able to run in Python, but it's useful to get into the habit now to make things easier later.</p>
print("Welcome to the course - you will learn to program!")
63
63
64
64
if __name__ == '__main__':
65
65
main()
66
66
</code></pre>
67
-
<asideclass="warning"><p><strong>Note:</strong> It is important to realise at this stage that <em>indentation</em> is critical in Python which is slightly different to other languages. The code snippet below is not the same as the one above and would result in an error.</p>
68
-
</aside>
67
+
<p>Negative : <strong>Note:</strong> It is important to realise at this stage that <em>indentation</em> is critical in Python which is slightly different to other languages. The code snippet below is not the same as the one above and would result in an error.</p>
print("Welcome to the course - you will learn to program!") #this indentation is wrong
71
70
if __name__ == '__main__':
72
71
main()
73
72
</code></pre>
74
-
<asideclass="special"><p><strong>Note:</strong> If you don't want or need to set up a local development environment at this stage, and you are happy working in Repl.it, you can safely <ahref="https://scott3142.uk/python-programming/codelabs/part-1/index.html?index=..%2F..index#0" target="_blank">skip ahead</a> to Part 1 of the notes. <br><br> If you are just starting out with Python and you're not planning to do any serious software development yet, this is probably the recommended course of action. <br><br> If you'd like to set up Python on your computer, gain an understanding of the command line and Git, carry on to the <ahref="https://scott3142.uk/python-programming/codelabs/local-development-environment/index.html?index=..%2F..index#0" target="_blank">next section</a>.</p>
75
-
</aside>
73
+
<p>Positive : <strong>Note:</strong> If you don't want or need to set up a local development environment at this stage, and you are happy working in Repl.it, you can safely <ahref="https://scott3142.uk/python-programming/codelabs/part-1/index.html?index=..%2F..index#0" target="_blank">skip ahead</a> to Part 1 of the notes. <br><br> If you are just starting out with Python and you're not planning to do any serious software development yet, this is probably the recommended course of action. <br><br> If you'd like to set up Python on your computer, gain an understanding of the command line and Git, carry on to the <ahref="https://scott3142.uk/python-programming/codelabs/local-development-environment/index.html?index=..%2F..index#0" target="_blank">next section</a>.</p>
<li>Get to grips with taking user input, loops and if statements.</li>
35
35
</ul>
@@ -66,15 +66,14 @@ <h2 is-upgraded>Improving the program</h2>
66
66
computer says lower
67
67
</code></pre>
68
68
<p>In the next exercise you will implement this program yourself in Python.</p>
69
-
<asideclass="special"><p><strong>Exercise - Guess the number <br><br></strong> Read the instructions for the exercise and commit the solution via Github. <br><br><ahref="https://classroom.github.com/a/_rKYt4oC" target="_blank">Accept exercise on Github Classroom</a></p>
70
-
</aside>
69
+
<p>Positive : <strong>Exercise - Guess the number <br><br></strong> Read the instructions for the exercise and commit the solution via Github. <br><br><ahref="https://classroom.github.com/a/_rKYt4oC" target="_blank">Accept exercise on Github Classroom</a></p>
<p>In the following exercise, you will implement this program in Python. Can you fix the two points described above?</p>
103
102
<p><em>Hint: You may want to use a list to store the guesses.</em></p>
104
-
<asideclass="special"><p>As a human, we might work out that there are some tricks to this game that make winning much easier. For example, if our first guess is exactly halfway between the two endpoints, we have the best chance of getting it right in the least number of moves possible. Can you implement this functionality? <br><br> Can you program the functionality that tracks how many guesses the computer took to get the right answer and see if it beats a user on average?</p>
105
-
</aside>
106
-
<asideclass="special"><p><strong>Exercise - Computer guess the number <br><br></strong> Read the instructions for the exercise and commit the solution via Github. <br><br><ahref="https://classroom.github.com/a/DBA_EnCh" target="_blank">Accept exercise on Github Classroom</a></p>
107
-
</aside>
103
+
<p>Positive : As a human, we might work out that there are some tricks to this game that make winning much easier. For example, if our first guess is exactly halfway between the two endpoints, we have the best chance of getting it right in the least number of moves possible. Can you implement this functionality? <br><br> Can you program the functionality that tracks how many guesses the computer took to get the right answer and see if it beats a user on average?</p>
104
+
<p>Positive : <strong>Exercise - Computer guess the number <br><br></strong> Read the instructions for the exercise and commit the solution via Github. <br><br><ahref="https://classroom.github.com/a/DBA_EnCh" target="_blank">Accept exercise on Github Classroom</a></p>
108
105
109
106
110
107
</google-codelab-step>
111
108
112
109
<google-codelab-steplabel="Wrapping it all up in a web app" duration="30">
<li>How to dynamically update a web app given user input.</li>
117
114
</ul>
@@ -129,27 +126,25 @@ <h2 is-upgraded>Getting started with Flask</h2>
129
126
app.run()
130
127
</code></pre>
131
128
<p>This code outputs "Hello, World!" in a web browser on your computer's localhost port 5000 (i.e. at <ahref="http://localhost:5000" target="_blank">http://localhost:5000</a>) when run with the <code>python3 app.py</code> command and the Flask library installed.</p>
132
-
<asideclass="special"><p>In order to do this on your own machine, you'll have to: <br><br> - <ahref="https://scott3142.uk/python-programming/codelabs/getting-started/index.html" target="_blank">Have Python installed</a><br> - <ahref="https://scott3142.uk/python-programming/codelabs/getting-started/index.html?index=..%2F..index#3" target="_blank">Activate a virtual environment</a><br> - <ahref="https://scott3142.uk/python-programming/codelabs/getting-started/index.html?index=..%2F..index#2" target="_blank">Install Flask inside your virtual environment using pip</a></p>
133
-
</aside>
129
+
<p>Positive : In order to do this on your own machine, you'll have to: <br><br> - <ahref="https://scott3142.uk/python-programming/codelabs/getting-started/index.html" target="_blank">Have Python installed</a><br> - <ahref="https://scott3142.uk/python-programming/codelabs/getting-started/index.html?index=..%2F..index#3" target="_blank">Activate a virtual environment</a><br> - <ahref="https://scott3142.uk/python-programming/codelabs/getting-started/index.html?index=..%2F..index#2" target="_blank">Install Flask inside your virtual environment using pip</a></p>
134
130
<p>You can set up a virtual environment and install <code>flask</code> using the following commands in a terminal:</p>
<p>Once you have done that, clone the exercise repo below and follow the instructions in the README.</p>
141
-
<asideclass="special"><p><strong>Exercise - Guessing the number in a web app <br><br></strong> Read the instructions for the exercise and commit the solution via Github. <br><br><ahref="https://classroom.github.com/a/ku4AAUEN" target="_blank">Accept exercise on Github Classroom</a></p>
142
-
</aside>
137
+
<p>Positive : <strong>Exercise - Guessing the number in a web app <br><br></strong> Read the instructions for the exercise and commit the solution via Github. <br><br><ahref="https://classroom.github.com/a/ku4AAUEN" target="_blank">Accept exercise on Github Classroom</a></p>
0 commit comments