Presentation is loading. Please wait.

Presentation is loading. Please wait.

Getting Started 27 June 2016 Week 1, Day 1. Who am I? Name: Christopher Little Town: Cambridge Eats: Chips.

Similar presentations


Presentation on theme: "Getting Started 27 June 2016 Week 1, Day 1. Who am I? Name: Christopher Little Town: Cambridge Eats: Chips."— Presentation transcript:

1 Getting Started 27 June 2016 Week 1, Day 1

2 Who am I? Name: Christopher Little Town: Cambridge Eats: Chips

3 Who are you?

4 Two double-lessons daily How we’re going to learn 11:00 13:00 9:00 Breaks at 10 : 00 and 11 : 45

5 How we’re going to learn 1. Listen (to me) 2. Confirm (for yourself) 3. Practice (makes perfect)

6 So much stuff! What are we going to learn?

7 Start Starting from total scratch Week 1 Setup Learning to Program Week 2 Web Programming Language Processing Week 3 Graphics Data Science Demo Day! Show off what you’ve learned! Zuzanna joins us

8 Plan for Day 1 1. Getting Started: Computer Setup What is programming? 2. Variables: Declaring and Assigning Types Arithmetic Operations

9 Computer Setup Getting Started

10 python.org Install Python github.com/Maximus5/ConEmu/releases (Windows Only) Install ConEmu tinyurl.com/ReachCompSci Bookmark Course Page sublimetext.com Install Sublime Text

11 What is a programming language? Getting Started

12

13 What is programming? Getting Started

14

15 Exercise 1.1 – A Tasty Algorithm 1. Look up a recipe for your favourite food 2. Rewrite this recipe into a step-by-step set of instructions for a slightly dim younger sibling 3. Convert your recipe into a flowchart ➡➡

16 The Python Interpreter

17 Exercise 1.2 - Learning Arithmetic Try out each of the following statements in the IDLE. How does each operator work? 5 + 2 5 - 2 5 * 2 5 / 2 5 ** 2 5 // 2 5 % 2 5 + 2 * 3 (5 + 2) * 3

18 Python Arithmetic Operators OperatorWhat it is + Addition - Subtraction * Multiplication / Division OperatorWhat it is // Integer division (round down) ** Exponent (power of) % Modulo (remainder) () Grouping

19 My First Function

20 Defining a function: def double(x): return x * 2 Using a function: double(4) # returns 8 double(-5) # returns -10

21 Exercise 1.3 – Your First Function Create a function which returns the next number in a sequence of your choice For example, for the sequence 0, 2, 4, 6, 8, … : myFunction(0) # returns 2 myFunction(2) # returns 4 myFunction(4) # returns 6

22 Exercise 1.3(b) – Your First Function Create a function which returns the nth number in a sequence of your choice For example, for the sequence 0, 2, 4, 6, 8, … : myFunction(0) # returns 0 myFunction(1) # returns 2 myFunction(2) # returns 4

23 Exercise 1.3(c) – Your First Function Create a function “ linear ” which takes three inputs - m, x and c - and calculates the y value at that point using the linear equation (y = mx + c)

24 Exercise 1.3(c) – Your First Function Create a function “ linear ” which takes three inputs - m, x and c - and calculates the y value at that point using the linear equation (y = mx + c) Extension: Create a similar function “ quadratic ” using the quadratic equation (y = ax 2 + bx + c)`

25 The Mighty print() Function

26 The Python Interpreter vs Python script files

27 Exercise 1.4 – A Short Biography Write a program that prints out the following on separate lines: 1. Your first name ‍ 2. Your age 3. How tall you are (in metres)

28 Types

29 Python Variable Types Python NameFull Name bool Boolean int Integer float Float str String

30 Variables

31

32 Declaring and Assigning Python Variables

33 Exercise 1.4(b) – A Short Biography Modify your biography program so that your details are stored in three variables. Print out the three lines as they were before.

34 The crafty input() function

35 Exercise 1.4(c) – Rewriting History Modify your biography program again. It must now: 1. Prompt the user for their name, age and favourite type of animal 2. Store these in a variable 3. Print on separate lines, as before

36 Exercise 1.4(d) – Rewriting History Modify your biography program again. It must now: 1. Prompt the user for their name, age and favourite type of animal 2. Store these in a variable 3. Print on separate lines, as before, but only using the print function once.

37 Day 1 Recap Python Basics: Installing What is programming? Arithmetic Operations Functions Interpreter vs Script files The print and input functions Types Variables

38 Now for the Challenges!

39 Exercise 1.5 – Fancy Receipts for a Fancy Shop Write a short program for generating nicely formatted receipts for a fancy boutique The user should be able to input 3 items, each with a short description and price, and these should be printed out after all three have been inputted

40 Exercise 1.5(b) – Fancyer Receipts for a Fancy Shop Write a short program for generating nicely formatted receipts for a fancy boutique The user should be able to input 3 items, each with a short description and price, and these should be printed out after all three have been inputted in a neat table, with the final total shown.

41 Exercise 1.6 – Quadratic Equation Solver Write a program that prompts the user for the variables a, b and c in the quadratic equation. Use the quadratic equation to find the two possible values for x such that ax 2 + bx + c = 0

42 Exercise 1.7 – Magic Mind Reader Write a program which: Asks the user to think of a number Asks the user to apply a series of arithmetic operations to their number, using another number as an example In the middle, cancel out the number with itself, so that the result is always the same. Amaze your user by telling them the resulting value!


Download ppt "Getting Started 27 June 2016 Week 1, Day 1. Who am I? Name: Christopher Little Town: Cambridge Eats: Chips."

Similar presentations


Ads by Google