CS 100

Logo

Scientific Computing

HW 3

Download and save the file hw03.py to your CS100/hw folder.

This file is a template. It contains some code there for you. Put your name at the top of the file. Run it first to test that it runs without errors.

I suggest you work one question at a time. Read the question description and write your solution. Before you move on, test that your solution is correct by uncommenting all lines of code which call the function at the bottom of the program. The first one is uncommented for you.

To help you check that your program produces the correct result, here is a sample output from my answer key. Your finished program should output the same once all your code is correctly added:

Q1 - testA: Python
Q1 - testB: Ada Lo
----------------------
Q2 - testA: bbage
Q2 - testB: ngine
----------------------
Q3 - testA: She envi ulators,
Q3 - testB: coining  cience'.
----------------------
Q4 - testA: 13
Q4 - testB: 22
----------------------
Q5 - testA: 1
Q5 - testB: 2
----------------------
Q6 - testA: vxre are some fun facts about vxr
Q6 - testB: Svx was tvx daughter of tvx English poet Lord Byron
----------------------
Q7 - testA: 97
Q7 - testB: 65
----------------------
Q8 - testA: 4
Q8 - testB: NOT FOUND
----------------------
Q9 - testA: A
Q9 - testB: B
Q9 - testC: C
Q9 - testD: D
Q9 - testF: F
----------------------
Q10 - testA: 0
Q10 - testB: 25
Q10 - testC: 24
Q10 - testD: -1
----------------------
Q11 - testA: A
Q11 - testB: a
Q11 - testC: Z
Q11 - testD: y
Q11 - testE: ?
Q11 - testF: ?
----------------------
Q12 - testA: HelloCS100,whatabeautifulday
Q12 - testB: computerscienceisawesome
----------------------
Q13 - testA: its a great day punctuation is my friend said ee cummings
Q13 - testB: whle  odded, early a, suddely there came a ta, as of some oe etly ra, ra at my chamber door.
----------------------
Q14 - testA (note that your password will be different each time): bbcbcacc
Q14 - testB (note that your password will be different each time): f1gg3121g133ff1
----------------------
Q15 - testA: True
Q15 - testB: True
Q15 - testC: False

There are multiple test cases for each problem to help you be certain that your functions work correctly. Use it to help debug your program if you encounter problems. For example, if your output doesn’t match what it should, then why is that? Is it the same for all tests? Does it produce similarly incorrect output (e.g., printing the first 7 characters rather than the first 6 characters)? A big part of programming consists of this debugging step!

Grading

You will be graded based on the quality of your code and that the output of each function matches the expected result. I will be checking to see that you correctly computed the solution programmatically.

In order to receive any credit, your program must run without syntax errors in Thonny. Thonny reports syntax errors in red in the shell area; if Thonny outputs an error, your code isn’t usable. Code that doesn’t run is just text - it’s not a program. It’s an important part of programming and problem solving to come up with a solution that can be shared with others.

Your program doesn’t have to be perfect to be eligible for credit! It’s okay to have some semantic errors, or missing answers. Semantic errors don’t stop your program from running, but they cause your program to produce an unexpected or incorrect result. For example, if your program is supposed to calculate the gross income for an employee, but instead it accidentally computes more or less money to be paid than what it should, that would be a semantic error. Semantic errors may result in partial credit depending on how close your solution is.

How to submit

Double check that your program runs without syntax errors. Submit the file updated with your changes to Moodle.