Presentation is loading. Please wait.

Presentation is loading. Please wait.

Design and Technology Academic Year 2017/2018 Grade 7 First Semester.

Similar presentations


Presentation on theme: "Design and Technology Academic Year 2017/2018 Grade 7 First Semester."— Presentation transcript:

1 Design and Technology Academic Year 2017/2018 Grade 7 First Semester

2 Contents Unit 1 Programming Why we learn programming Unit 2
Python introduction Combining number and strings Unit 3 IF statements Comments Flowcharts and pseudocode Loops For loops Loop in a loop Unit 4 Arrays Secret messages Unit 5 Coding challenges Ask them if they know python or familiar with programing languages, make differentiation as you see fit

3 Algorithm for making a cup of coffee
Learning Development Unit An algorithm is a list of steps you give to computers to solve a problem or get something done. Algorithm for making a cup of coffee 1. Get a cup 2. Add 1 teaspoon of coffee to the cup 3. Add water to the kettle 4. Boil the water 5. Add the boiling water to the cup within 2cm of the top 6. Get milk from the fridge 7. Add 1cm depth of milk to the top 8. Stir the coffee 9. Put milk back in fridge Give them a fast explanation of algorithms

4 Decomposition Learning Development Unit When you break a problem down into smaller parts to make it easier to tackle. Making a computer game is quite a complex problem. You could solve this by breaking it down into smaller tasks. Simple explanation - getting something big into small parts and combine them together

5 Flowcharts Check your handout Flowchart demonstration
Learning Development Unit` Check your handout Flowchart demonstration

6 Introduction to Python
Learning Development Unit Introduction to Python Ask them why we like python for kids, not java for example , the answer is – less brackets and prentices which make the code easier for the kids to understand, simple english coding

7 Python setup Python 3.X https://www.python.org/downloads/
Learning Development Unit Python 3.X Py Charm Edu (Editor) How to install python

8 Use python online Go to , click on New in the top right corner, select python 3 and start coding If they don’t have python on laptops make them open python online

9 Practical Activity Write your first program in Python
Learning Development Unit Write your first program in Python Show them around python program, libraries section on left side – coding on right side- output in the buttom

10 “Hello World” print("Hello Program")
Learning Development Unit print("Hello Program") In python we can use ‘ instead of “ For instance print ( ‘ Hello world ‘ ) is also right. Hello world program

11 What is a Syntax Error? Syntax error – is writing a code in a wrong way , big letter for example or missing bracket etc A syntax error is when you try and run the program and it will not run due to the syntax not being correct. If you made a spelling mistake, or missed a character out a program will not compile until all syntax errors are corrected. Programmers also call these ‘bugs’. Common errors include not closing the speech marks “”, using “ and ‘ symbols instead of the speech marks, missing a bracket, spelling mistakes and incorrect capital letters.

12 What is Debugging ? De-Bug
Debugging – finding what is wrong in code and fix it , in here we have a missing ( “ ) next to Python Finding the problems in code is known as debugging. No one is perfect, computer programmers sometimes make mistakes when writing their code. An important part of programming is testing your program and 'debugging’ (which means removing the bugs).

13 Activity Write a program in Python which prints the following information in multiple lines. first name last name your school name your favorite hobby This is the expected output. Give them 5 minutes to finish the activity

14 What is a Function ? Its also called a Method
Here print is a function and it is also highlighted in different colour automatically What is a function – in here we have print function as an example Did you notice how easy it was write make the computer display messages. All you needed to write was print() and the computer did the rest. We call this a function. This means that python knows what print() means and does all the fancy computer things to make whatever is shown between the brackets display on the screen.

15 Output When something is processed by the computer and returned back we call this the output. In the pictures below identify which one is input and which one is output? Input Input and output explained Output

16 Hint Quick Quiz Which of these line of code is correct?
Print ("Hello world!") print ("hello world!") print (hello world!) print "hello world!" Hint Let them have 1 minute to think of it , click again to show them the hint if needed, then show the answer

17 Write some code so that the computer will show the text of your name.
Learning Development Unit Practical Activity Write some code so that the computer will show the text of your name. Take feedback How easy did you find this activity?

18 Working with numbers Operation Operator Example Python Add + 5 + 5
Learning Development Unit Working with numbers Operation Operator Example Python Add + 5 + 5 print (5+5) Multiply * 2 * 4 print (2*4) Subtract - 10 – 5 print (10-5) Divide / 10 / 2 print (10/2) Explain the operations

19 Perform a calculation using each of the operators +, -, * and /.
Learning Development Unit Code Challenge Perform a calculation using each of the operators +, -, * and /. Let them have 2 minutes to write a python calculation How easy did you find this activity?

20 Code Challenge Answer tell the teachers - Did you notice that you did not need to write the = symbol like you do in maths? This is because = has another meaning in programming. We will learn about this later on – equal sign will be used in variables and strings

21 Notes Operation Output 11/4 2.75 11//4 2 11%5 1
Learning Development Unit There is also another way of dividing. If you use two forward slashes instead of one, Python will produce an integer as an answer. An integer is a whole number, for example 2. A decimal number is called a float, for example 2.5. You can now find the remains, with another math operated called the modulus. This is a % sign. Operation Output 11/4 2.75 11//4 2 11%5 1 Explain 3 types of division

22 Practical Activity Learning Development Unit Try out each of the operators shown in the table. Do they give the correct answers? Also try out some of your own sums. If the past activity – writing a mathematical operation was easy – there is no need to do this activity

23 For example: print(“2*3”)
Quick Quiz Learning Development Unit What happens if you put a math sum inside speech marks in the print() function? For example: print(“2*3”) Brain storming question, output will be 2*3 not 6 because we used (“ “ ) marks which will see the numbers as part of the text

24 Here Calculations and 2*3 is treated as string
Learning Development Unit In programming, A string is a data type used in programming, such as an integer and floating point unit, but is used to represent text rather than numbers. It is of a set of characters that can also contain spaces and numbers. For example, the word “Hello" and the phrase "I work 18 hours a day" are both strings. Even "12345" could be considered a string, if specified correctly. Typically, programmers must enclose strings in quotation marks for the data to recognized as a string and not a number or variable name. Here Calculations and 2*3 is treated as string Explain the string to them – its like a box that contains text data

25 Combining text and numbers
Learning Development Unit It is possible to join text (or strings) and numbers in the print() function. A comma (,) is used as a separator between the text and the math. Joining multiple print methods using ( , ) inside the print method

26 Can you work out what the output from this code will be?
Quick Quiz Learning Development Unit Can you work out what the output from this code will be? Let them have 1 minute to give you the answer of this code before they try it on their laptops

27 Learning Development Unit
What is a Variable ? A variable is like a box that you can save information inside. Each box has a label so you know what it is called. You can change what information is inside the box, but the label will stay the same. Variables are used to store numbers as data Click to show the answer Explain variables – like a box that contains numbers as data

28 Creating a variable Learning Development Unit To start with, we create a variable and then assign a value to it. We assign a variable using the = symbol. This is why we do not use the = symbol when making math calculations. Open the Python window. Type in the following and run it. falcons = 4 quiz : try to print falcons using print function How to make a variable and a quick quiz for 1 minute

29 Code the following height = 6 width = 8 area = height * width
Learning Development Unit Code the following height = 6 width = 8 area = height * width print (area) Explain to them what this code will give us, and let them write it on their laptops focus on that we merged two variables together ( height and width) in one variable ( area )

30 Learning Development Unit
End of Part 1 Have a break

31 String Type the code: textSting = “I am a string”
Learning Development Unit String Type the code: textSting = “I am a string” Notice that a string uses quotation marks the same as when we used the print function. Try the code below and see if works. Let them write a string

32 Do you know what is Input function ?
Learning Development Unit Do you know what is Input function ? We use another built in function called input(). This function is very similar to the print() function, it can be given a string which it sends to the screen. It takes one string each time input() is used. The program waits for the Enter key on the keyboard to be pressed. Explain input method – it’s a method that allows user to insert the data he wants The most common input is asking the user to type something into the program. When we want to get the user to interact with the program we call this an input. So far we have used input() as an input method. keyboardinput = input(“Enter some text please.”)

33 Learning Development Unit
Output When the computer sends back data for example displays something on the screen, this is known as an output. So far we have used print() as an output. Make sure they understand that we use print to see the output of anything in python

34 name = input (“What is your name”)
Learning Development Unit Practical Activity 1. Open a new Python program and type the following code: name = input (“What is your name”) 2. Run the code. It should look like this. What is your name? At the moment, the program simply saves whatever the user types in a variable that is called name, but it does not display it back (output). 3. Add this line of code at the end of the program. print(name) When we do this the contents of the variable called name is displayed on the screen. explain this to them and let them write it in python

35 Joining strings together
Learning Development Unit Joining strings together Strings can be joined together by using the + symbol. For example we can create a new variable called “fullName” by joining “firstName” and “lastName”. Practical Activity Open Python and write the following code firstName = input ("What is your first name?") lastName = input ("What is your last name?") fullName=firstName+lastName print(fullName) How to join two strings together using ( + ) symbol – see next slide for an example

36 Combining numbers and strings
Learning Development Unit Combining numbers and strings When you use the input() function, Python automatically creates the users input as a string. Remember we learned earlier that a string can only be used to store text. So, what if we want to perform a mathematical function on a user’s input? Check the code below, can you find something not familiar so far ? The int function in the 3rd line is a new function how to insert a mathematical operation using the input method – explanation next slide

37 Int() function Example
Learning Development Unit Int() function To perform a mathematical function on a user’s input, we must convert the string to an integer. We use the int() function and inside the brackets we write the String name that we want to convert to a variable. Example work out how old the user is by subtracting their age away from the current year, e.g – 2003 means the user is aged 14. We use int method ( int stands for integer ) to define the input as a number instead of a text

38 Important notes for int()
Learning Development Unit Important notes for int() If you know your answer will be a number, you do not have to save in a string and covert it to a Variable. You could skip this step by using int(input()) Using this will automatically convert the input “ which is a string” to an int “which is a variable“. Merging int and input in one line For example: age = int(input("How old are you?"))

39 More Methods Learning Development Unit We can use methods in Python to change the way the text looks, for example we might want all CAPITAL LETTERS. The next table shows the actions we can perform on text entered. More methods you can explain easily from the chart

40 It can be done in multiple ways
Learning Development Unit “changes only the output” firstName = input ("What is your first name?") print(firstName.upper()) “overwriting the same string” firstName = input ("What is your first name?") firstName = firstName.upper() print(firstName) Explain the 3 codes , first one is normal print, 2nd one we overwritten the string into it self to have full upper case letters always , 3rd one has less coding lines “less code lines” firstName = input ("What is your first name?").upper() print(firstName)

41 Code Challenge Create a program that asks the user: • Their name
Learning Development Unit Create a program that asks the user: • Their name • Their address • Their address Output on the screen as: • Name in capitals • Address in sentence form • address all lowercase Hint first line firstName = input ("What is your first name?") print(firstName.upper()) Let them have 5 minutes to write the code

42 Code Challenge How easy did you find this activity?
Learning Development Unit How easy did you find this activity?

43 If Statement Ask them what they think of the if statment
Learning Development Unit If Statement Ask them what they think of the if statment

44 True or False or maybe something in between ?
Learning Development Unit True or False or maybe something in between ? If stamen explained , let them brain storm their ideas about if statment

45 How it works If statement uses operators to make a decision.
Learning Development Unit How it works If statement uses operators to make a decision. If the statment is true, the code continues. if the statement is false, the code move to next condition or stops if there is nothing left Operators of the if statement

46 if else statement example
if statement example Learning Development Unit if else statement example If statement and if else statement ,let them write the codes and see if they understood it

47 elif statement example
Learning Development Unit elif statement example Elif is an else if staatment , if you have multiple scenarios elif is what we use

48 Learning Development Unit
Loops Ask them about loops and what they know about it In general, statements are executed sequentially: The first statement in a function is executed first, followed by the second, and so on. There may be a situation when you need to execute a block of code several number of times. A loop statement allows us to execute a statement or group of statements multiple times. The following diagram illustrates a loop statement

49 Types of Loops Loop Type Description
Learning Development Unit Types of Loops In general, statements are executed sequentially: The first statement in a function is executed first, followed by the second, and so on. There may be a situation when you need to execute a block of code several times. Loop Type Description while loop Repeats a statement or a group of statements while a given condition is TRUE. It tests the condition before executing the loop body. for loop Executes a sequence of statements with a defined number of times and abbreviates the code that manages the loop variable. nested loops You can use one or more loops inside any another loop Loops explained

50 while loop example Nested loop example for loop example counter=10
Learning Development Unit while loop example Nested loop example for loop example counter=10 while counter>0: print ("Value of a is",a) counter = counter-2 print ("Loop is Completed") num=2 for counter in range (1,6): print (num * counter) In groups let each group type one of the 3 loops and see if they have it correct, ask them some questions about it , see if they can track its process , explain how it moves on the board if needed , draw and demonstrate how the code moves

51 Learning Development Unit
Thank you


Download ppt "Design and Technology Academic Year 2017/2018 Grade 7 First Semester."

Similar presentations


Ads by Google