Computational Thinking is the thought processes involved in formulating problems and their solutions so that the solutions are represented in a form that can be effectively carried out by an information-processing agent
Jeannette Wing
TL;DR Problem solving by you, or a machine, in a way that is simple to reproduce
This is not a quick course to learn Python. First and foremost, this is Computational Thinking through the medium of Python.
This could (almost) as easily be taught using any language. There will be much more to learn about Python after this course but you will be better equipped to learn it.
In [3]:
"Hello, People"
Out[3]:
HIGH LEVEL OVERVIEW Files are run line by line at runtime (no need to compile). Some checks are done before the file runs (spacing, module imports etc), but errors are typically not caught until that line of the file is executed.
In [6]:
"Hello, Python" #press enter here
"My name is <your name here>"
Out[6]:
Ever used a different language with semicolons and curly braces?
Python does not have that. EVERYTHING revolves around whitespace. Indentation us key and enforces clean code
We will cover this as we go on but be careful about spacing errors
Do not worry about the code for now, but take a look at how this works:
In [4]:
for i in range(0,100):
print("bloop")
In [5]:
for i in range(0,3):
print("bloop")
The example in the previous slide told you the error and the line it occured on, like this:
Always use this before you ask/search for the problem. The error text is what you should search for as well. We cannot answer questions like: "Why is my code not working?" any more than you can.
"I am trying to print a string at line 11 and it is giving me an indentation error" Saying something like this out loud (or in your head) may actually help you resolve the problem. That being said: we are here to help and never be afraid to ask for it, it is what you are paying for
What happens when you remove the print and the brackets?
A REPL is designed to show you the state of things with each command. So, typing:
"print me"
will print that string.
Scripts (or files) will not do this unless you tell it to.
This is partly because printing to the command prompt (also called: stdout) is one of the slowest operations you can perform in Python!
First port of call: This course and recommended reading
Second port of call: the interpreter (Learn by making mistakes. Fixing bugs and errors will increase your knowledge exponentially)
Third port of call: The Python docs
Fourth port of call: The Python docs
Fifth port of call: Us. Stop us and ask and we will do our best to help!
Sure?
Fine: Stack Overflow
Beware, Python 3 is new and not all the code you find online will run. Any code written in Python 2.* will not be marked or accepted.
The Jupyter notebook is a way of running code in the slides, providing answers to exercises and experimenting with any code samples provided. This first lecture was provided as a PDF but there is an ipynb file also included on Learning Central.
Every session will have at least a PDF and an ipynb file. In order to run that file (and interact with the code samples), you need to run:
jupyter notebookPlay arrow or by pressing Ctrl-Returnjupyter notebookhttp://localhost:8888Play button
In [ ]:
language = "" #insert the language we are coding in here
print(language)
Here, you have set the variable language to the value Python. What do you note that is different here over a language like C#? Give me 2 differences.
char x = 'y';
Console.WriteLine(x);
C# requires you write the type of the variable as well as the name. Why do you think Python doesn't?
There is a semicolon at the end of the line. Python relies on whitespace instead of expression terminators.
Finally, Python calls print while C# calls Console.WriteLine. A chocolate bar for anyone that can tell me the difference:
Python has print as a function but WriteLine is a method attached to the Console Object.
Do not worry, all of this will be covered in depth in the course.