In order to write relatively simple programs, there are just a handful of basic concepts you need to get you head around.

The best way of learning is by doing things but a little bit of theory can help put things into context.

So, here are just a few ideas that will help to get you into the swing of programming and see that, fundamentally, it’s not that complicated.

Learning Python 1: the Basics of Programming

The fundamentals of programming in Python are not that difficult, as we shall see

medium.com

What is a computer program?

print("Hello")

That’s about the simplest programs you can write in Python; it’s a simple statement that, as you no doubt realise, prints “Hello” on the screen.

It is simple, but it is a complete program.

Computer programs are made up of a sequence of statements that are instructions for the computer to do something (print on the screen, for example).

Sequence

Program statements are executed one at a time, in sequence.

print("Hello Arthur")
print("Hello Ford")
print("Hello Zaphod")

This bit of code simply prints three different messages on the screen.

Selection

However, some programming statements let you make decisions — this is called selection.

If a certain condition is met then you do one thing, otherwise you do something else. (For example, if you know someone’s name, you could print “Hello name”, otherwise just print “Hello”.)

if name == "unknown":
   print("Hello")
else:
   print("Hello ",name)

This code checks to see if something called _name _has the value “unknown” and then if that is true, it prints the message “Hello”. Otherwise we assume that _name _has a valid value (e.g. “Albert”) and the code prints the message “Hello name” instead.

#programming #learning #deep learning

Programming: It’s Easier Than You Think
1.25 GEEK