Sunday 10 August 2014

4. Maths





In these lessons we are going to look at the ease with which you can use Python to perform mathematical calculations.  Many of you will have covered this in KS3 so hopefully we should cover this section very quickly.

LEARNING OBJECTIVES

You will learn to:
Describe and use mathematical operators
Combine calculations with text
Describe the use of parenthesis and use of procedure

TASK 1

Copy and run these lines of code. Complete the table to explain what the mathematical operators do.
>>> 60/5
>>> 987+34
>>> 564*89
>>> 2**5
>>> 43-5
>>> 11//2
>>> 11%2

In a Google Doc make and complete the following table and link to your learning blog.

Mathematical operator symbol
Operation
/

+

*

**

-

//

%

 TASK 2

Using Python make up some mathematical calculations of your own and add an example to the table for each mathematical operator.  
A) Screen dump your calculations into a Google Doc and link to the learning blog.  

B) Also, complete the table with example calculations and an answer.

Mathematical operator symbol
Operation
Example
Answer
/
divide


+
add


*
multiply


**
exponential


-
subtract


//
integer division


%
modulus (remainder after the division)



TASK 3

A) Write a program to display this text on the screen and fill in the missing number.
8 cats have 4 legs each
The cats have ___ legs in total

B) Write a program to display this text on the screen and fill in the missing number.









A farmer with 1089 sheep sells 56 of them
The farmer has _____ sheep left


C) Write a program to display this text on the screen and fill in the missing number.









4 children pick 56 flowers each
The children each have ____ flowers

TASK 4

Copy and run these lines of code. What effect do the parentheses () have?
>>> 5 * 3 / 6 + 4
>>>(5 * 3) / (6 + 4)

TASK 5

Predict what you think will be displayed on the screen when this line of code is executed.
15 / 2 * 3 + 2
Now copy and run the code. Explain the answer you get. Is it what you predicted?
HOMEWORK
In a Google Doc  
Make up some multiple-choice questions on precedence. Each question must have four possible answers, one of which is correct.
Here are two examples:
What is the correct answer to the following expression?
>>> 7 + 4 * 5


A) 55 B) 27 C) 16 D) 33







What is the correct answer to the following expression?
>>> 6 -2 / 2 + 5

A) 0.57 B) 10 C) 7 D) 11

Check your answers are correct by using the interactive Python shell.
Try your questions out on other people. You must be able to explain to them why the answers are correct.


No comments:

Post a Comment