EGR 103/Fall 2018/Lab 3/InLab
Jump to navigation
Jump to search
Here's a general overview of what I went over during the lab; be sure to also check the Fall_2018/Lab_3 Lab 3 self-guided tour and rad the lab document! Things in those two items are not replicated below.
Contents
Problem 1
- Input is assumed to be some number of seconds
- Output would be a tuple of hours, minutes, and seconds
- Examples:
- hms(60) should be 0, 1, 0
- hms(4012) should be 1, 6, 52 -- there are 3600 second in an hour, and 3600 fits once in 4012. Of the remaining 412 seconds, there are 60 seconds in a minute which gives 6 whole minutes and 52 seconds left.
- As usual, figure out how you work the problem, then write the code.
- Note that a//b will give you the number of whole b's in a; a%b will give you what is left over after taking out as many whole b's as possible
- Neither a nor b need to be an integer!
- 4.2 // 1.5 is 2.0 and 4.2 % 1.5 is 1.2
- The code I gave takes input and returns a tuple of all zeros - these should eventually be replaced with the hours, minutes, and remaining seconds you calculate.
- You do not need to make any changes to the test_time code - simply run it and enter your NetID when asked. It will print to your screen and save to a time_diary.txt file; the former is so you can see what the tester did and the latter is so you can include that text in your lab report.
- The code to import the diary has a comment in LaTeX - once you have created the diary, be sure to go into emacs and into your lab3.tex code to remove the comments in front of the \lstinputlisting line appropriate for that diary.
Problem 2
- First three inputs are required, fourth is an option input (default is 0)
- Book has equation for Law of Cosines\[c^2=a^2+b^2-2ab\cos(\theta_c)\]
- Note that to draw a closed triangle you need to give the plot command a total of four coordinate pairs.
- Current code has imports and function definition line; you need ad calculating angles, making plot, and returning values.
- When evaluating logic, generally any non-zero, non-False value is considered True. This means
if draw:
will run the code it controls if the draw variable contains anything other then 0 or boolean False. - Loops and ifs and whiles need to have at least one active line of code to work - a good placeholder is
pass
- The test code will ask for your NetID and then run your program 4 times. It will produce a diary for the lab report and four graphs for the appendix.
- If one of the triangle PDFs or diary files is open, the test code may not be able to run due to permissions. If you preview PDF files, close them before re-running the tester.
- Your code does not need to check for valid values - assume the user gives you sides that work.
Problem 3
- Components between 0 and 2.375
- For single numbers a and b: max(a, b) returns the number closest to +infinity; min(a, b) returns the number closest to -infinity.
- Calculations over the course of a season of about 100 are excellent.
- Calculations for a single game may have a wild range.
- The test code will ask for your NetID and run your program several times and save a diary.