EGR 103/Fall 2019/Lab 4

From PrattWiki
Revision as of 01:33, 17 September 2019 by DukeEgr93 (talk | contribs) (4.5.1 Sinusoidal Functions)
Jump to navigation Jump to search

Errors / Additions

None yet!

BASH Shortcuts

During lab, we will set up your account to have two new Unix shortcuts to make working with labs a little easier. To make this work, you will need to follow the instructions at BASH Shortcuts to:

  • Create a ~/.bashrc file in your home directory with the contents described on BASH Shortcuts
  • Create a ~/.bash file in your home directory with the two functions (get103 and ltx) described on BASH Shortcuts

From this point forward, every time you log in those shortcuts will be available. To make them available immediately without having to log out and log back in, you will need to type

source ~/.bashrc

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() (or, in our case, ax.plot()) command to change sizes and colors.

4.5.2 Based on P&E 4.48

The heart of this code will be nested for loops and proper format specifiers to make sure things fit.

4.5.3 P&E 2.3.8

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

4.5.4 Beam Deflection

While this references 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.

4.5.5 Geometric Progressions

Among other things, this problem looks at input validation. You will definitely want to check out the section on Python:Iterative_Structures#while_loops While Loops on the Python:Iterative_Structures for help in identifying type errors with the input. You will also want to make sure you think about how you will be checking for valid inputs and then write and test the code for each problem case.

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