9
Introduction to Computing Using Py Group practice in problem design and problem solving In this lesson, you will work together in small groups to design a programming problem such as might be given on a test (15-20 minutes) submit your problem to a Moodle forum solve one or two of the problems your class designs (15-20 minutes per problem) (one group should) present a solution (~10 minutes) (each person should) rate the programming problem for difficulty

Cs100 2014F Lecture 09 ProgrammingPractice

Embed Size (px)

DESCRIPTION

CS 100 Python

Citation preview

Slide 1

Introduction to Computing Using PythonGroup practice in problem design and problem solvingIn this lesson, you will work together in small groups todesign a programming problem such as might be given on a test (15-20 minutes)submit your problem to a Moodle forumsolve one or two of the problems your class designs (15-20 minutes per problem) (one group should) present a solution (~10 minutes)(each person should) rate the programming problem for difficulty and clarity

Introduction to Computing Using PythonDesign a programming problemWork together in small groups (for example, of three) to design a good programming problem (15-20 minutes)Your problem might be similar to Question 13 on Midterm 2. It would have these elementsspecify that the reader write a function that takes a file name as a parameterdescribe the content of the file (e.g., text or numbers or a combination; including punctuation or not ... )specify a property of the input file that the function should computespecify whether to write the result to an output file or to return the result in a dictionarygive an example of correct input and output

Introduction to Computing Using PythonThe content of the input fileThe input file could have any content made up of characters (text)It might be line-by-line content, such asA name followed by height and weightThe lines of a poem or lyricA year followed by the 10 most popular baby names for that yearOr it might be a block of text consisting of words separated by white space (white space includes spaces, tabs and end line characters)Or it might be a sequence of numbers (integers or floats)Use your imagination!

Introduction to Computing Using PythonTell the problem solver to analyze ...Some property or relationship of the elements on each line A person's name and the person's zodiac signLength of the line (in words or characters) or the number of short words on a line, or the number of big numbers on a line ... ORSome property of the words in the file (without regard to the line structure)Length of words, or frequency of wordsDistribution of upper and lower case charactersWords beginning (or ending) in a certain way, or containing certain charactersHint: what is to be analyzed will determine whether the solution should read the file all at once (using the read() method) or line by line (using a for loop or readline() or readlines() method)

Introduction to Computing Using PythonHow hard should your problem be?Give your problem a reasonable level of difficultyA problem with a 3 line solution is probably too easy A problem with a 30 line solution is probably too hardTry to make the problem solver do some thinking ... (minutes of thinking, not hours)Make the solution use some combination (not necessarily all!) of things we have learned, such asdata types (strings, lists, numbers)built-in operators and functions (in, not, len(), range() )methods (append(), count() )flow control structures such as the for loop and if statement

Introduction to Computing Using PythonHow to describe the problemMake your description of the problem as clear and simple as possibleBe specific about the parameters (input) to the function and the output of the functionGive helpful hints and guidanceInclude a good example of input and outputThe example should be short enough so that the problem solver can follow your instructions for analyzing the input to arrive at the outputThe example should illustrate how to handle any different cases of input and clarify possible pitfalls

Introduction to Computing Using PythonSolve the problem (15-20 minutes)Work together in your small group to solve the problemRead the problem carefully. Discuss it and make sure that you agree on what it is the problem asks you to do.Work the example. Make sure that you arrive at the correct output. Share ideas how to approach the problemWhat value(s) do you need to keep track of? What variables do you need to store these values?Are there repeated operations? What control structure (loop) governs the repetition?Are there conditional operations? What are the conditions (Boolean expressions) for doing or not doing the operation?Make sure your code works on the example givenCreate your own test case and try your code on it

Introduction to Computing Using PythonPresent your solution (~10 minutes)At the end of the allotted time, one group should present their solutionIn your own words, present your understanding of what the problem asks you to doReport the state of your solutionWhat is the core problem and how does your code solve it?Your solution may not be complete or fully correct. (That is a common state of affairs.) Convey the state of the solution, including any problems that you are aware ofDoes your code run or does it terminate with an error message?Does your solution give the same output as the example?If the output is not correct, where do you think the problem might lie?

Introduction to Computing Using PythonRate the problemEach person should rate the problem (for example, by a show of hands)On a scale of 1 to 5, how clear is the problem description?On a scale of 1 to 5, how difficult is the problem?Is the problem a reasonable test of what we have learned so far this semester?