Practice?
APT Quiz 2 from Fall 2019
APTs
See below for hints on what to do if your APT doesn't run.
For each problem in an APT set, complete these steps by the due date
- Submit the code for grading using the Submit link. You may submit as many times as you want to test your code and the last submission will count for grading.
- Check your grade on the grade code page by clicking on check submissions
- Fill out the REFLECT form for each APT you do to give us feedback on that problem and to certify that you understand the code for that APT.
In solving APTs, your program should work for all cases, not just the
test cases we provide. We may test your program on additional data.
Problems Running an APT? Some Tips!
- Make sure you have the correct file name, file names are
case-senstive and in .py
- Make sure you have the correct function name, beginning with
def as the first line of your
function definition.
- Always start with return 0 or return "" or
return [] to see if your function name and file are correct.
You
won't have the correct answer but you should have the red and green boxes.
- Do you have the correct type of value to return? If the function is
suppose to return an integer, are you returning an integer?
- If you are getting timelimit exceeded and have tried all the things
above, put in a print statement at the top of your function such as
print ("starting function")
When you run it, does that show up?
- Sometimes the editor you are using tries to "help you" and adds in an extra strange
import statement
at the top of your program, e.g., something like
from StdSuites.Text_Suite import word
Remove such imports.
- If you are not passing all the tests but cannot figure out what is
wrong with your code, then try copying your code into Python Tutor. You
will also need to add a statement to call the function with some
input. Then you can trace through it in Python Tutor and see the values of
variables. If you have long statements like:
x = stuff.lower().find('x')
Break them into more lines and add more variables so you can see the
intermediate results. Such as:
temp = stuff.lower()
x = temp.find('x')