Revision Python - Nick Reynolds April 7, 2017 Revision (~15 mins) - - PowerPoint PPT Presentation

revision
SMART_READER_LITE
LIVE PREVIEW

Revision Python - Nick Reynolds April 7, 2017 Revision (~15 mins) - - PowerPoint PPT Presentation

Revision Python - Nick Reynolds April 7, 2017 Revision (~15 mins) This Class Quiz (45 mins) Practical Revision Conditionals and or Whats the difference? Revision If it is raining and I am going outside, take an


slide-1
SLIDE 1

Revision

Python - Nick Reynolds April 7, 2017

slide-2
SLIDE 2

This Class

  • Revision (~15 mins)
  • Quiz (45 mins)
  • Practical
slide-3
SLIDE 3

Revision

slide-4
SLIDE 4

Conditionals

slide-5
SLIDE 5

Revision

and or What’s the difference?

slide-6
SLIDE 6

Revision

If it is raining and I am going outside, take an umbrella. If it is raining or I am going outside, take an umbrella.

slide-7
SLIDE 7

Revision

If raining and goingOutside: takeUmbrella() If raining or goingOutside: takeUmbrella()

slide-8
SLIDE 8

Revision

If raining and goingOutside: takeUmbrella() elif not raining and goingOutside(): takeHat() else: makeCoffee()

slide-9
SLIDE 9

Loops

slide-10
SLIDE 10

Revision

foods = ["Apple", 'Orange'] for _____ in foods: ...

What goes here?

slide-11
SLIDE 11

Revision

foods = ["Apple", 'Orange'] for anything_you_want in foods: ...

Any variable name you want

slide-12
SLIDE 12

Revision

foods = ["Apple", 'Orange'] count = 0 while count < len(foods): print(foods[count])

Have I forgotten anything?

slide-13
SLIDE 13

Revision

foods = ["Apple", 'Orange'] count = 0 while count < len(foods): print(foods[count]) count += 1

Need to increment count!

slide-14
SLIDE 14

Functions

slide-15
SLIDE 15

Revision

def highest(num1, num2): ...

What are these?

slide-16
SLIDE 16

Revision

def highest_print(num1, num2): if num1 > num2: print(num1) else: print(num2) def highest_return(num1, num2): if num1 > num2: return num1 else: return num2 What’s the difference?

slide-17
SLIDE 17

Revision

>>> highest_print(1, highest_print(3, 4)) # Error! >>> highest_return(1, highest_return(3, 4)) # 4

Return decides the result of the function Print just prints out to the console This evaluates to nothing!

slide-18
SLIDE 18

Pen and Paper

Quiz (45 mins)

slide-19
SLIDE 19

Practical & Assignment 1

slide-20
SLIDE 20

References

  • http://pwp.stevecassidy.net/python/more-

python.html

  • https://thenounproject.com/