Presentation is loading. Please wait.

Presentation is loading. Please wait.

Design a Problem Solution. Making a design In this class we use the words “design”, “pseudocode” and “algorithm” interchangeably These are steps to solve.

Similar presentations


Presentation on theme: "Design a Problem Solution. Making a design In this class we use the words “design”, “pseudocode” and “algorithm” interchangeably These are steps to solve."— Presentation transcript:

1 Design a Problem Solution

2 Making a design In this class we use the words “design”, “pseudocode” and “algorithm” interchangeably These are steps to solve a problem, they involve writing down a design for the solution A design is similar to a rough draft or an outline for an essay It’s meant to be a thinking tool, it will not be neat. You will make corrections, additions, deletions, reorderings

3 Problem – build a dog house

4 Building a dog house 1.decide on location for house 2.decide on size of house 3.get plans for house 4.get materials for house 5.cut wood for bottom of house 6.put bottom platform together 7.cut wood for 4 walls of house 8.assemble walls 9.attach walls to bottom 10.cut door 11.make roof 12.attach roof to walls 13.paint outside

5 Notes about the design The steps are numbered in the order they will be done – we will ask you to do that for the first few designs you do, just to get the feel for how much is one “step” Several of the steps should be subdivided, like step 4 would include the store you would buy the materials from, a list of the materials needed, possibly prices Step 7 could be written as a repetition Repeat 4 times cut wood for a wall The order of several steps can be rearranged, like step 10 could be after step 11 Several steps could have more detail – the size of the dog would determine the size of the house, the location would depend on the size of the yard, the climate, the direction the house faces, Some people would make notes about insulation or a fan or A/C Assumptions about budget would be noted at the top

6 Building a dog house (with some refinements) 1.Decide on location for house 2.Decide on size of house 3.Get plans for house 4.Get materials for house 1.Get lumber 2.Get insulation 3.Get paint 4.Get nails 5.Cut wood for bottom of house 6.Put bottom platform together 7.Repeat 4 times 1.Cut wood for a wall of house 8.Assemble walls 9.Attach walls to bottom 10.Cut door in front side of house 11.Make roof 12.Attach roof to walls 13.Paint outside

7 How to do a design in this class Use an editor that creates a text file. The editors from IDLE or WingIDE work fine. Notepad is also ok. State the purpose of the design at the top Put your name, section and email at the top Number the steps (hint: wait until you have the design finished before you number the steps, aggravating to have to renumber) Enter the steps in the editor as Python comments, using # or ‘’’ Write the steps in English, NOT Python!

8 Program design (in a file called design1.py) #Purpose: ask for a user’s name and say hello to them # Author: John Smith, section 1, john.smith@uky.edu #The main function #1. input the user’s name from the keyboard #2. output the name with the word hello before the name Save this as something like design1.py You ask why do I save it as a Python file? This file will be the basis of the actual implementation (Python) file Just load it into your editor and write Python code to do each step of the design – voila! You have your documentation done!

9 Implementation with design between code lines (in a file called greeting.py) #Purpose: ask for a user’s name and say hello to them # Author: John Smith, section 1, john.smith@uky.edu #The main function def main (): #1. input the user’s name from the keyboard name = input(“Your name? “) #2. output the name with the word hello before the name print(“Hello”, name) main()


Download ppt "Design a Problem Solution. Making a design In this class we use the words “design”, “pseudocode” and “algorithm” interchangeably These are steps to solve."

Similar presentations


Ads by Google