In this brief introduction to programming you have seen the fundamental building blocks that almost every programming language provides:
- variables and assignment (
=
) to store and update data - arithmetic operators (
+
,-
,*
) - simple data types (strings and numbers, both integers and floating point)
- data structures (lists)
- sequence (one instruction per line)
- iteration (
for
andwhile
loops) - selection (
if-else
andif-elif-elif-...-else
), - comparisons (
>
,<
,==
,!=
,>=
,<=
) - functions (
len
andsum
for lists,int
andfloat
to convert strings to numbers) - input from the keyboard (
input
function) - output to the screen (
print
instruction)
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.
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.
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.
Like learning any other skill, only practice makes perfect. We hope this tutorial inspired you to learn more Python and to share your creations with friends and family.
Rate and Review
Rate this activity
Review this activity
Log into OpenLearn to leave reviews and join in the conversation.
Activity reviews
Colin Malarkey - 17 December 2018 7:24pm
Will be doing TN112 soon, so found the activities helpful and fun.
Colin Malarkey - 17 December 2018 7:25pm
TM112 apologies...
Clear and helpful introduction