Lesson 4
To be able to:
A computer program is a set of commands that tell a computer what to do.
A command is an instruction that tells the computer to perform an action.
A snake case variable name is one that includes underscores in the name
For example:
number_of_sweets = 0
However, a camel case variable name uses the capital letters to replace the underscores.
For example:
numberOfSweets = 0
Have a go at the following activity in your notebooks, it can be found under the "Python Programming" section.
Data is the characters and symbols we type into a computer
Data types are how those characters and symbols can be categorised.
The two types of data types we will discuss today are:
In computer science there are several types of numbers, but our focus is on whole numbers and numbers with a decimal point.
A whole number is called an INTEGER
10, -5, 0, 25000
A number with a decimal point is called a FLOAT
1.5, 0.5, -2.75
In computer science we refer to general text as a STRING
Strings are enclosed by quotation marks ""
These are examples of strings:
"Hello", "Side Effect?", "£10.25", "Lesson 1"
Note that strings can contain numbers and punctuation symbols so long as it is enclosed between quotation marks.
A function is a group of instructions given to a computer.
Here is an analogy :
You may be asked to jump:
Jumping entails a group of actions such as to squat, move your legs
You may be asked to wave:
Waving entails a group of actions such as to shake your hands or perform a jazz hands
jump and wave are examples of functions
jump and wave are the names of the functions
In addition you can provide extra information to the function to get it to do more.
For example:
You could tell the jump function how many times the character should jump:
jump(5)
You could tell the wave function how quickly you want the hands to wave:
wave(2)
These numbers are examples of ARGUMENTS.
EVERYBODY up on your feet!
Functions will appear on the board
YOU are the characters!
wave(1)
jump(3)
wave(6)
wave(10)
jump(6)
wave(100)