1 – First Steps

🎯 Learning Objectives

Develop the Programming and Development and Algorithms Learning Strands:

  • Describe what algorithms and programs are and how they differ
  • Recall that a program written in a programming language needs to be translated in order to be executed by a machine
  • Write simple Python programs that display messages, assign values to variables, and receive keyboard input
  • Locate and correct common syntax errors
💬 Key Vocabulary
  • algorithm
  • program
  • programming
  • language
  • assignment
  • program
  • translation and execution
  • interpreter
  • programming
  • environment
  • input
  • output
  • variables

🔎 An Introduction to Python

Last year, you…

  • Used a block-based programming language (Scratch) to create programs that involved:
    • Variables, operators, and expressions
    • Sequence, selection, and iteration
    • Subroutines
    • Lists

In this unit, you will…

  • Use a text-based programming language (Python) to build on these concepts and extend them.
📖 Learn It – Algorithms
  • An  algorithm is a set of precise instructions, expressed in some sort of language (e.g. textual, visual).
  • Understanding the language is necessary in order to execute the instructions.
  • Executing these instructions is meant to solve a problem.
📖 Learn It – Programs
  • A  program is a set of precise instructions, expressed in a programming language.
  • Translating the programming language is necessary for a machine to be able to execute the instructions.
📖 Learn It – Python programs
  • To execute a Python program, you need a Python interpreter.
  • This is a program that translates and executes your Python program.
📖 Learn It – Syntax
  • All programming languages have rules for syntax, i.e. how statements can be assembled.
  • Programs written in a programming language must follow its syntax.
  • Programs with syntax errors cannot be translated and executed.
  • All languages have rules for syntax, i.e. how sentences can be assembled.
  • Speech or text in a language must follow its syntax.
  • Humans can infer meaning even in cases when syntax rules are violated:
For example, “tonigth see you”, instead of “see you tonight”, will probably be understood.
  • In Scratch, syntax errors are not possible: rules are enforced by the blocks and the way they fit together.
  • You can still make logical errors! That’s when your program doesn’t work the way it should.
if remaining < 10:
  print("We are getting there")
else:
  print("Still some way to go")

  • In Python, you can (and you will) make syntax errors. You will need to follow the syntax rules.
  • Syntax errors can be frustrating when you start learning a text-based programming language.

📝 Try It – Main Activity

  • You will be using pair programming, with each member in a pair taking on a specific role:
    • Driver: Controls the keyboard and mouse
    • Navigator: Provides support and instructions
  • You will alternate between roles.
  • Open the Thonny program on your computer, or download it from here.
  • Then follow the instructions on the worksheet and the instructions given by your teacher.

In this lesson, you…

  • Defined what algorithms and programs are
  • Wrote and executed your first Python programs (and weeded out syntax errors)
  • Your programs involved displaying messages, assigning values to variables, and receiving input from the keyboard

Next lesson, you will…

  • Use arithmetic expressions to calculate values
  • Trace the values of variables as a program is executed
  • Write programs that receive numerical input from the keyboard

🏅 Badge it

🥈 Silver Badge
🥇 Gold Badge
🥉 Platinum Badge
  • Use the knowledge you have gained in today’s lesson to make your own problem that uses variables, assignment and input to create an original program. Use the snipping tool to screenshot your program and copy it into the bottom of your worksheet before uploading.