Bitpath

Lesson 1 · Unit 01

Values and expressions

Numbers, text, print and arithmetic

13 exercisesabout 3 min

What you practise

  • Numbers and text, print, arithmetic and its order, //, % and **, text in quotes, a program runs one line at a time

Try a question from this lesson

Pick one

This is a whole program, one line long. What do you think it shows on the screen when it runs?

Python
print(2 + 3)

The ideas

Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.

Concept

Your first program

A program is a list of instructions. Python runs them one line at a time, from the top down.

print(...) is an instruction that shows a value on the screen. A value is a piece of data, such as the number 10.

Anything after a # is a comment: a note for people. Python skips it.

Python
print(10)       # shows 10
print(4 + 6)    # also shows 10

Concept

Operators

+, -, * and / are operators: they combine two values into a new one.

/ always gives a number with a decimal point. // divides and throws the remainder away. % gives only the remainder. ** is "to the power of".

Python
print(8 / 2)     # 4.0
print(7 // 2)    # 3
print(7 % 2)     # 1
print(2 ** 3)    # 8

Concept

Strings

Text inside quote marks is called a string. Single or double quotes both work, as long as the string ends with the kind it started with.

With strings, + joins and * repeats.

Give print several values with commas between them, and it shows them on one line with spaces.

Python
print("Hi " + "Ada")     # Hi Ada
print("ha" * 3)          # hahaha
print("Total:", 5 + 1)   # Total: 6

9 more exercises in the app

  • 3× type the answer
  • 2× multiple choice
  • 1× fill the blanks
  • 1× match the pairs
  • 1× true or false
  • 1× order the lines

Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.

One email when Bitpath is ready to try. Nothing else. Privacy