EGR 103/Fall 2018/Lab 4

From PrattWiki
Jump to navigation Jump to search

Errors / Additions

None yet!

4.1 Introduction

The main purpose of this lab will be to look at selective and iterative structures and to learn about logical masks. The following is a companion piece to the lab handout itself. The sections in this guide will match those in the handout.

4.2 Resources

See main EGR 103 page for links to these

4.3 Getting Started

Same as it ever was.

4.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.

4.5 Assignment

4.5.1 Sinusoidal Functions

See the Python:Plotting page as well as the matplotlib.pyplot.plot page for information about the additional pieces of information you can give the plt.plot command to change sizes and colors.

4.5.2 P&E 2.32

The heart of this code should be a nested set of for loops. You will need to think about how to compare the final two digits of the square to the two digit number as well as how to make sure the square is a three digit number before printing a solution.

4.5.3 P&E 2.33

The brute force method here has several loops! Truly brute-forcing it (which is not the best idea) would take 8 loops. By carefully considering the hints, you can eliminate two of the loops. Once again, however, the goal is to have Python have to loop through several possibilities without your having to do more than the most basic work of establishing what M is and what Y would be for given values of D and E.

4.5.4 P&E 2.3.8

The solution to this will require understanding recursion, which requires understanding recursion. For on that in lab.

4.5.5 Beam Deflection

While this reference the Chapra book, you will not need to bring the Chapra book to lab - I will have the figure available on screen when we discuss the problem. The main concepts here are using logical masks to create piecewise functions, using different sets of points for mathematical analysis versus graphing, and determining and locating extrema as discussed in Plotting.

General Concepts

This section is not in the lab report but rather has some items in it that span multiple problems in the lab.

Determining and Locating Extrema

See Python:Plotting#Using_Different_Scales for some examples.

Logical Masks

See Python:Logical Masks.


Class Document Protection