Python Programming

Lesson 4

Learning Objectives

To be able to:

 

  • Define a computer program
  • Define Snake Case and Camel Case variable naming
  • Give examples of and translate between Snake Case and Camel Case variable names
  • Name and define different Data Types

Computer Programs

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.

Variable Names

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

Activity

Have a go at the following activity in your notebooks, it can be found under the "Python Programming" section.

Data Types

Data Types

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: 

  • Numbers 
  • Strings

Data Type - Number

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

Data Type - String

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.

What are Functions?

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 

What are Functions?

jump and wave are examples of functions

 

 

jump and wave are the names of the functions

What are 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.

Lets have a go!

EVERYBODY up on your feet!

 

Functions will appear on the board

YOU are the characters!

Lets have a go!

wave(1)

Lets have a go!

 

jump(3)

Lets have a go!

 

 

wave(6)

Lets have a go!

 

 

 

wave(10)

Lets have a go!

 

 

 

 

jump(6)

Lets have a go!

 

 

 

 

 

wave(100)