Presentation is loading. Please wait.

Presentation is loading. Please wait.

Training & Development

Similar presentations


Presentation on theme: "Training & Development"— Presentation transcript:

1 Training & Development
Python cover up G10 Training & Development

2 Previously Learned All Python Basics Functions concepts
Loops and arrays Debugging Complex python concepts Conditional statements

3 Learning outcomes After completing this unit, you will be able to:
• Describe a variable and Identify some data types. • Decompose computing problems using functions. • Store and retrieve data from a database and Debug computer programs. • Design and write a program in Python. Fast walkthrough: CSS is a language that allows you to make designs that are well organized and beautiful. HTML describes the content of web pages. CSS describes how that content should look. CSS provides a way to control the layout and presentation of an app. It is used to change the elements properties, including colour, font, size and placement. You will use CSS to make your app look great!

4 Key terms revision Important Vocab

5 Flow Chart Symbols Revision

6 Example flowchart for a program to add two numbers.

7 CCQ Flow Chart Can you design a flowchart to check if you have a new message?

8 Operators Revision Operators are used to process data such as adding or dividing. In the example below, the computer program will add two numbers. The answer is stored in total.

9 Data in Python Static By using direct data entry to the print function Variable By using data containers then using the print function on those containers to export their data String data type its any text wrapped by quotation marks “Hello String” Question what is the data type for “situation” and “age” and why Datatypes are used to label the data used in a computer program. Datatypes tell the computer how to store the data. They also tell it the type of operations that can be done on the data. Datatypes: integer: whole numbers such as -3, -2, 110, 0, 77. You can carry out: addition, multiplication, subtraction and division operations on integers. float: numbers with decimal fractions such as 90.34, 0.0, , , -9.22, They are also called real numbers. You can perform: addition, multiplication, subtraction and division operations on floating point numbers. string: text data; In Python strings are declared by enclosing the data with “”. Examples include: “Hello World”, Ali”, “Serena”, “23L” and “train” Numeric data type its any number that is not surrounded by quotations

10 Discussion Is this is a Swap program ? Justify your answer
Fill in string red Fill in string green Is this is a Swap program ? Justify your answer colour1 = “red” colour2 = “green” colour1 = colour2 colour2 = colour1 print(colour1,colour2) variable called colour1 Variable called colour2 No its not Colour1 copies colour2 variable called colour1 Variable called colour2 colour2 copies colour1 variable called colour1 Variable called colour2

11 CCQ Datatypes 1 , 2 ,3 ,10 ,100000 integer integer
“ hello” , “ my name is Taj” 2.3 , , integer integer char float string

12 Changing datatypes When you enter data, it will usually be stored as a string. You need to tell the computer if you want to use it as an integer or a real number. It depends on what you need in your program. Use the functions shown below to do this.

13 High and low level programming languages
You will use a high-level programming language to turn your algorithm into a computer program. You will use Python in this course. We can understand high-level programming languages, but computers can’t. They understand low-level languages or machine language. Machine language is in the form of 0s and 1s. The Python program you write will be translated by an interpreter into a low-level language for the computer.

14 Activity 1 3.14 Low 2 Points 377 newPoints 379, 2, 377
totalPoints , points , newPoints None 3.14 2 377 379, 2, 377 None

15 Activity 2 falconWeight totalLives life tabletPrice sdPrice sumPrice
400 3 1 1900 134 2168

16 Key Terms Revision

17 Conditional Statements Revision
We use simple conditional statements to compare values. You will write conditional statements using variables, numbers and relational operators. The result of simple conditional statements is true or false.

18 CCQ Conditional Statement
z < 500 y==0 y>z z>x y==z True False

19 Logical Operators Revision
You will use logical operators to join simple conditional statements to make compound conditional statements.

20 Conditional Statements - IF
Example Explain the IF statement using the given 2 examples The if statement will only execute a code block if the condition is true. It skips over the code block if the condition is false.

21 Activity 3 Give them 2 minutes for each part to solve it before showing them the answer The following message is printed for the second case: You can now get a driving license. Go and apply at the nearest driving school. The conditional statement evaluates to true for the second case so the code below the IF is executed. The following message is printed for this case: You can now get a driving license. Go and apply at the nearest driving school. The conditional statement evaluates to true for the case; therefore, the code block below the IF is executed Nothing is printed for the first case is smaller than 18 in the first case so the conditional statement evaluates to false. The code below the IF is not executed.

22 Activity 4 Give them 5 minutes to solve part a 1 minutes part b 1 minutes part c The code block will be executed. Your speed is over the speed limit. The simple conditional statement for the if statement is not true. Therefore, the code block will be executed. Your speed is below the speed limit; the code block will be skipped.

23 Conditional Statements – IF Else
The if-else statement chooses between one of two blocks; the code block after the if or the one after the else.

24 Activity 5 Give them 5 minutes to solve part a before showing them the answers , then other 5 minutes for part b

25 Conditional Statements - elif
The elif statement combines the else and if and allows us to add more than one conditional statement. For the case of the boiling water, we need to tell the user if the water is frozen, cold, warm, hot, very hot or boiling. We have more choices to select from depending on the value of the temperature entered. In this case, the if and if-else statements are not enough.

26 Activity 6 Give them 5 minutes to solve first part of the activity then other 5 minutes to solve part 2

27 While loops While loops will repeat the same code block as long as the result of the conditional statement remains true. The number of times that the code block is repeated is unknown. The conditional statement controls when to repeat the code block under the while.

28 Activity 7 Give them 3 minutes to solve the first two parts then other 3 minutes to solve the other three parts

29 Activity 8 Let them have 5 minutes to solve this activity then show them the answer

30 Activity 9 Give them 5 minutes to solve the first part then other 5 minutes to solve the 2nd part

31 For loops The for loop is used to repeat a code block a known number of times. For example, you go to school for five days a week. You repeat the same actions of getting up and going to school five times a week

32 range() Before advancing with Loops we must understand the range function Examples range([start], stop[, step]) start: Starting number of the sequence. stop: Generate numbers up to, but not including this number. step: Difference between each number in the sequence. it generates a list of numbers, which is generally used to iterate over with for loops. There's many use cases. Often you will want to use this when you want to perform an action X number of times, where you may or may not care about the index. Other times you may want to iterate over a list

33 Key Terms Revision

34 Can you Add and call the function for multiplication ?
Functions CCQ Activity Can you Add and call the function for multiplication ?

35 What is Debugging? Programming errors are called bugs and the activity of finding them and fixing them is called debugging. Debugging will help you understand what your code is doing. Debugging is like fixing a car. You may have some clues about what is not working properly. You must use the clues to find and fix the problem. You may even have to run your own tests to discover more clues. Once you have an idea about what is going wrong, you fix your program and try again. If your fix was correct, you take a step closer to a program without bugs

36 How do we use it? To start debugging, click "Run  Debug".
we can see the value of variables as we go through the program line by line. We can compare the actual value of variables to what we expected them to be during execution.

37 What are breakpoints and how do we use them?
Write the code Below and let us add a breakpoint by clicking on the area between the line number and a line in the program. When we debug the program, it will stop at the line with the red dot, the breakpoint We can now see the value stored in the variable at this point. Our program is displayed in the debug console with inline comments. We use breakpoint to see what our code is doing on specific lines. You can run one line of code at a time and see what is happening inside the program as each line executes. It is a lot easier to figure out what is going wrong in the code

38 Debugger If we use the debugger without any breakpoints it won’t help us much with debugging. Without breakpoints, the debugger will run through the code like normal.

39 Stepping though the program
The Resume Program option will execute the code until a breakpoint is reached The Step Into option will execute a function. The Step Over option will skip over a function that you have not started to execute The Step Out option skips the remaining part of a function that you are currently executing The debug console becomes active when you reach a breakpoint in your program. You can use the debug functions to control the execution of your program. Stepping is a debugging feature that allows you to execute your code one line at a time. You can then check if each line of code is doing what you want it to do.

40 Further explanation for stepping options

41 Evaluate expression The program is now stopped at the breakpoint on line 4. Clicking the Evaluate Expression box will open a console that will allow you to run expressions on variables The Evaluate Expression option is another option that we can use to debug a program. When a program is stopped at a breakpoint, we can use Evaluate Expression to perform expressions such as arithmetic operations on variables in the program

42 Evaluate Expression Console
breakpoint expression result console At this point in the program, the myNumber variable is equal to 12. We performed an expression on the variable to check if its value is greater than 5. The results of the expression are displayed in the result console. The result of this expression was equal to true: 12 > 5 = True.

43 Activity 10 Bugged Statments Debugged statments print(Hello World!")
Debug the statements in the table below. Bugged Statments Debugged statments print(Hello World!") Print("iPhone 7") print("Samsung S8" 12 = age 3.14 = pi 2+1) print("Hello World") print("iPhone 7") print(“Samsung S8”) age = 12 pi = 3.14 Let them have 5 minutes before showing them the answers (2+1)

44 Activity 11 myNumber = 5 myNumber = 12 myNumber = 10 myNumber = 9
What values are stored in the variables at the breakpoints shown in the table? myNumber = 5 myNumber = 12 Let them have 5 minutes before showing them the answers myNumber = 10 myNumber = 9

45 Syntax Errors Spelling a python keyword incorrectly.
2. Forgetting to add a colon at the end of the header of every compound statement, Syntax errors occur when a programmer does not follow the rules of the programming language. For example, you need to have an opening ( and a closing ). The program will not run if it has any syntax errors. The error messages produced and syntax highlighting will tell you where to search for the cause of the errors. 3. Unclosed "", ( ) and {}. 4. Using a Python keyword as a variable name.

46 Syntax Errors 5. Using “=” instead of “==” inside a conditional statement. 6. Incorrect indentation Continuing to previous slide

47 Activity 12 Debug the following syntax errors
Let them have 10 minutes to copy and debug the codes before you show them the answers

48 Runtime error explanation
Runtime errors occur after the program has started running. Runtime errors provide you with a traceback similar to the one shown. The traceback gives you clues about why the error happened. The following traceback tells you which file the error occurred in. In this example, the file is HelloWorld.py. It also tells you which line caused the error and the reason for the error. In this case the line with the error is the line with print(myFirstVariable). The error was caused by an undefined variable.

49 Runtime errors Spelling variable or function names wrong.
2. Using a variable before it is defined 3. Passing the wrong number of arguments to a function. Explain the types of runtime errors 4. Dividing by zero.

50 Activity 13 Debug the following Code blocks
Give them 10 minutes to debug the errors then show them the correct answers

51 Taj project deTH NOTES Scenario
VR – videos and applications-(Modelling!) Link to the topics Advanced – Parallel processing - little Encryption – write code for decryption

52 Thank You Note for QA Team, waiting for CS CDU team to Provide Project Based Content


Download ppt "Training & Development"

Similar presentations


Ads by Google