Professional Documents
Culture Documents
Lesson 1
An introduction to Computer Science and Python 3
www.teachyourselfpython.com
www.teachingcomputing.com
Series Overview
Information/Theory/Discuss
Task (Code provided)
Challenge (DIY!)
Suggested Project/HW
*Please note that each lesson is not bound to a specific time (so it can be taken at your own pace)
INFORMATION IS POWER! .and learning how to code is going to give you power.
How will you use it? Be inspired and you will really enjoy TeachingYourselfPython!
?
John Von Neumann was an amazing man (left). He was a child prodigy and legend has it he made his secondary
school maths teacher weep at his sheer genius even at that young age! Here he is with one of the worlds first
computers it was called the MANIAC.
>
The Maniac was the computer that was used to perform the calculations that led to the creation of the atomic bomb.
The devastation that followed is something you would have read all about .
So . information is POWER but how we use that power is what is really important! Quantum Computing is
another emerging field that has great potential but also very great security risks. Well come to that in a later lesson.
In small and big ways, computer science is continually providing opportunities to do good, solve problems and
change the world. Every field imaginable is now reliant on Computer Science. Lots to think about! Once youre a
competent computer programmer, what will you use your skills to do?
https://www.python.org/downloads/
We have downloaded Python 3.4.3
1
5
Number 1
4
7
Number 2
A useful analogy
Variables are like storage boxes that can hold or store values in
them.
47
Variable Name:
NumberToStore
Joe
FirstName
Try chatting with these bots. Can you tell you are not talking to a
real person. How do you know? How could the program be
Recent Developments in AI
You may find Wikipedias timeline of AI interesting reading (see link
below)
https://en.wikipedia.org/wiki/Timeline_of_artificial_intelli
Googles artificial
gence
intelligence (AI)
software has been
developed to the
point that it is ready
to go head to head
with the worlds
highest ranked GO
This is seen
as a pivotal moment for AI, similar to IBMs DEEP BLUE
player.
beating Gary Kasparov at chess!
OM
RAND
T
OUTPU
The examples above generate random numbers and random items from a list.
NUMBERS
STRING
LIST
TUPLE
DICTIONARY
long
51924361
float
0.0
complex
3.14
Operatio
n
?
?
?
?
?
?
?
Example
s
Code
Meaning
?
?
?
?
?
?
Increment Operators
Incrementing is something that we will be using a lot as seen below
you can also shorthand the code:
Operator
Shorthand
Predict the
output
?
Block 1 = Line
4
Block 2 = Line
Block 36 = Line
8
https://youtu.be/poLZqn2_dv4
https://youtu.be/667ZeuZ0Q8M
DESIGN
CODE
TEST
An Example
DESIGN
TEST
CODE
Test Data
Expected
Output
Actual
Output
Testing for
correct
name input
John
Validated
Validated
Test was
successful
Testing for
numeric
input
validation
Only
Numbers
allowed
J was
accepted.
Test
FAILED
TEST (white box and black box) Prove the solution works!