Computational Thinking The problem solving process is Define

Computational Thinking

The problem solving process is: � Define � Prepare � Try � Reflect 2

Definition: � Problem Solving Skills � Logical and critical thinking � Looking to the problem and solving it systematically and arriving to solution that both human and computers understand � Highest order problem solving � There are four elements of computational thinking (Decompose-pattern matching. Abstraction- Algorithm) 3

In order to solve any problem you need to � Decompose: Break a problem down into smaller pieces � Pattern Matching: Finding similarities between things � Abstraction: Pulling out specific differences to make one solution work for multiple problems � Algorithm: A list of steps that you can follow to finish a task 4

� To develop a computer solution (program) for any problem, we need to have a problem-solving method �Analyze the problem and outline it and its solution requirements �Design an algorithm to solve the problem �Implement the algorithm in a programming language, such as (Python, Java, …). Coding �Verify that the algorithm works Testing �Maintain the program by using it, and improving and modifying it if the problem domain changes 5

6

Start Problem definition Implementation phase Analysis Translating to Computer Program (Coding) Design Testing Problem-solving phase Working program 7

Problem: Add two numbers Solution: � Use problem solving steps (next). 8

� Step 1: Define (understand) the problem �Clearly state and understand the problem �May be the most difficult phase �Failure to understand the problem is the major cause of most project failures 9

� Step 2: Analysis �What are the inputs and Outputs Input: Data, Information Output: result, feedback �How the inputs can be used to produce the desired outputs (Model equation) 10

� Step 3: Design �Algorithm: the exact steps used to solve a problem �Represented using a pseudo code or a flowchart �Flowchart: a pictorial representation of the logic steps �Pseudocode: English-like representation of the logic 11

� Step �To 4: Coding implement the solution (write a program) Select the programming language Write the instructions 12

� Step 5: Test and Correct the program �Testing: method to verify correctness of the solution �Execute it with sample data and check results �Identify logic errors (bugs) and correct them �Choose test data carefully to exercise all branches of the logic 13

�A set of instructions, performed sequentially with no branching. 14

Break down the problem using computational thinking skills. � Problem definition: � Decomposition of the problem: � Input: � Output: � Pattern Matching: � Abstraction (abstract the differences): � Algorithm:

Problem: Compute the area of the room Solution: � Step 1: Problem definition �To compute the area of the room. � Step 2: Analysis �Input: length and width �Output: area �Model: area = length * width 16

� Step 3: Design �Algorithm (step by step solution) a. Start b. get the length c. get the width d. Compute area = length e. show output f. Stop/End * width 17

start terminator get length input/output get width area=length *width Processing (computing) show area Input/output Stop Flowchart: using basic shapes to represent the algorithm terminator 18

� Step 4: Coding �Transfer the algorithm to a computer program �We’ll work on the Python language during the term � Step 5: Testing �Manual computation: Assume length= 5 and width =4, then the area should equal: 5 * 4=20 �Compare the manual computing to the program output. �Correct your program , if needed. 19

1. 2. 3. 4. Read in the radius of circle, then compute and print its area and circumference. Compute and print and employee's salary given the hours worked and the hourly rate. Given a temperature in degrees Fahrenheit, compute and print the equivalent temperature in degrees Celsius. If a human heart beats on average once a second, how many times does the heart beat in a lifetime of 60 years? (use 365. 25 for days in a year)? 20
- Slides: 20