year 7 lesson 2 text and maths

9

Click here to load reader

Upload: tmoncrieff

Post on 23-Jun-2015

145 views

Category:

Education


1 download

DESCRIPTION

Lesson 2 - Introduction to Python

TRANSCRIPT

Page 1: Year 7 lesson 2   text and maths

TEXT

& MAT

HS IN

PYTH

ON

L ES

SO

N 2

Page 2: Year 7 lesson 2   text and maths

LESSON OBJECTIVES

Learn how to use Python to work out maths calculations.

Page 3: Year 7 lesson 2   text and maths

LESSON OUTCOMES

I can use more text in Python ... I can use basic maths in Python ... I can use both text and maths in Python programming ...

Page 4: Year 7 lesson 2   text and maths

[ slide 4 ]

STARTEREscape sequences have a special purpose in Python.

See below:

Complete Task 1 on Worksheet 2 to try out escape sequences in your own code.

Lesson outcomes I can use more text in Python ...

I can use basic maths in Python ...

I can use both text and maths in Python programming ...

Page 5: Year 7 lesson 2   text and maths

[ slide 5 ]

PYTHON AS A CALCULATOR

Now complete Task 2 on Worksheet 2 to try out some more basic maths in Python.

Lesson outcomes I can use more text in Python ...

I can use basic maths in Python ...

I can use both text and maths in Python programming ...

Open Python Shell and have a go at the calculations in the table below:

Page 6: Year 7 lesson 2   text and maths

MINI PLENARY

In pairs try

the Mini Plenary task on Worksheet 2.

Did the calculator beat Python??

Lesson outcomes I can use more text in Python ...

I can use basic maths in Python ...

I can use both text and maths in Python programming ...

Page 7: Year 7 lesson 2   text and maths

[ slide 7 ]

COMBINING MATHS & TEXT

What will the output from this code produce?

>>> print("11 divided by 4 = ", 11//4, "remainder ", 11%4)

>>> print("111 divided by 4 = ", 111/4)

>>> print("11 divided by 4 = ", 11/4)

Now try Task 3 on Worksheet 2.

Lesson outcomes I can use more text in Python ...

I can use basic maths in Python ...

I can use both text and maths in Python programming ...

Page 8: Year 7 lesson 2   text and maths

MORE TEXT AND MATHS ...

We can use text to label numbers for example: coins = 20 Why???

Reason: If we need to demonstrate how many coins we own more than once and the value of the coins change, we only need to change the number at the start of the program once.

As programmers this can saves us lots of time.

Now try Task 4 on Worksheet 2.

Page 9: Year 7 lesson 2   text and maths

[ slide 8 ]

PLENARY

The escape sequence \n is used to create a ...

The escape sequence \t is used to create a ...

The operator * is used to ...

The operator / is used to ...

The operator // is used to ...

You can also f.... numbers to create a decimal.

Lesson outcomes I can use more text in Python ...

I can use basic maths in Python ...

I can use both text and maths in Python programming ...