3. Conditionals
Feel free to use your laptop if you have it
Ensure I have recorded your completion — failure to do so will result in a grade of 0
I strongly encourage you to work with others in the lab
When you get stuck, do me a favour and ask those sitting around you for help
I want people to get used to working together in the labs
Peer teaching and peer learning is super effective
Note
To obtain full marks for the lab, you must:
Have completed the pre-lab exercises
Have been working on the lab content
Demonstrate competency in the topics
3.1. Pre Lab Exercises
Warning
You must have completed the specified exercises prior to the start of the lab. If you have not come to lab prepared, you will be asked to leave and you will obtain a grade of 0 for the lab.
-
1
10
11
Write assertion tests for each of your functions above
3.2. Before Kattis
Write a function
did_pass(grade: float) -> bool:
that returnsTrue
if the grade is 50 or above, andFalse
otherwiseBe sure to write some
assert
tests to verify correctness
Write a function called
letter_grade(percent_grade: float) -> str:
that takes a grade as a percentage and returns the appropriate letter grade0 - 49 -> F, 50 - 59 -> D, 60 - 69 -> C, 70 - 79 -> B, 80 - 89 -> A, 90 - 100 -> A+
Write
assert
tests to verify correctness
Rewrite
letter_grade(percent_grade: float) -> str:
such that you reverse the order you check the grade inFor example, if you checked
if grade < 50:
first, start with checking for an A+Run the
assert
tests from the previous question
3.3. Kattis Problems
Do not forget the code we used last time to read input on Kattis
1data = input() # Read a WHOLE, SINGLE line of input
2data = data.split() # Split string into individual pieces
3a_var = int(data[0]) # Take string from data[X], convert it to int...
4b_var = int(data[1]) # ... And store it in some variable
Warning
The above code will only work when the input is 2 integers on the same line. You may need to hack this code to make it work for your particular problem.
Warning
Ensure that your your completion has been recorded. Failure to do so may result in a grade of 0.