EGR 103/Spring 2020/Lab 5

From PrattWiki
Revision as of 03:01, 12 February 2020 by DukeEgr93 (talk | contribs) (Created page with "<div class="noautonum">__TOC__</div> == Errors / Additions == None yet! == 5.1 Introduction == The main purpose of this lab will be to look at debugging, dictionaries, loadi...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Errors / Additions

None yet!

5.1 Introduction

The main purpose of this lab will be to look at debugging, dictionaries, loading data from files, and using Chapra Figure 4.2. There is also some string manipulation.

5.2 Resources

See main EGR 103 page for links to these

5.3 Getting Started

EGR 103/Getting Started

5.4 Ungraded

These problems are good ones to look at and to solve but are not a part of the graded work. Given that, you can absolutely consult with classmates about how to get the answers to these ungraded problems but you may not share those answers outside of the members of the class.

5.5 Useful Information

String and List Functions

This section discusses some of the most common functions applied to strings or to lists.

Debugging Introduction

See the videos at:

We will also go through debugging in lab using the Python:Debugging page.

5.6 Group-Based In-Lab Autograded Assignments

Both of these require building dictionaries and using them.

5.6.1 Based on P&E 9.26

For this problem it will be easy enough to simply hard-code the dictionary in the make_dict function. For example, one line in the function might look like:

    d[0] = "zero"

5.6.2 Based on P&E 9.32

For this problem, you could hard code all the values but what you might want to do is create a dictionary by first creating a list of the letters and then a list of the point values. If you have those two lists, you can create the dictionary in two different ways:

Using a loop

If the lists are called LETTERS and VALUES, respectively, you could create a dictionary with code like the following:

d = {}
for k in range(26):
    d[LETTERS[k]] = VALUES[k]

Using zip

There is also a built-in function in Python called zip that will take the two lists and basically make a dictionary for you. If the lists are called LETTERS and VALUES, respectively, you could create a dictionary with code like the following:

d = dict(zip(LETTERS, VALUES)

See Section 9.7 of Punch & Enbody for examples of zip.


5.7 Individual Lab Assignment =

5.7.1

This problem takes you step by step through developing the code. Pay careful attention to the tests it recommends that you run. Put those tests in your script either in a main() function that gets called or in a selective executable based on whether __name__ is "__main__". Also look at the test code - make sure you understand what it is doing and how it works.

5.7.2

This is similar to 5.7.1. Including the part about looking at the test code and seeing how it works.

5.7.3

For this one, you will be making changes to an extended version of the Chapra 4.2 code in order to use accumulation to estimate values of cosine. It is very similar to using an accumulation to estimate values of the exponential.

5.7.4

For this one, you will be making changes to either the original or extended version of Chapra 4.2 in order to use a mapping to estimate roots of a function. It is very similar to using the Newton method mapping to estimate values of a square root. Note - though the mapping for the lab assignment comes from the Newton-Raphson, it origin is different from the Newton method discussed in class for finding a square root.

Class Document Protection