APT Quiz
Start the APT quiz on Sakai under quizzes, but not until you are ready to
take the quiz.
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
- first click on the APT set below to go to the APT page.
- write the code, upload the file and click the Submit
link
- check your grade on the grade code page
by clicking on check submissions
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.
We may do some APTs partially in class or lab, but you still have to do
them and submit them.
There will usually be extra apts listed. You can do more than required to
challenge yourself. We do notice
if you do more APTs than those required.
If you do extra APTs, they still have to be turned in on the due date.
Regrades
If you have concerns about an item that was graded (lab, apt or
assignment), you have one week after the grade is posted to fill out the
regrade form here.
Problems Running an APT? Some Tips!
Here are some suggestions if your APT does not run. THESE ARE COMMON
ERRORS CompSci 101 STUDENTS MAKE.
- Make sure you have the correct file name, including case.
- Make sure you have the correct def statement, the first line of your
method definition. Strongly recommend you cut and paste it.
- If you get the error wrongclass, which might show up as:
logged entry score = wrongclass
Then you may have forgotten to select the button beside the name of the
APT. The tester needs to know which APT you are trying to test.
- If you don't get any gray or green boxes, try commenting out the code
for your function and just return something simple, return 1 if the return
type is an integer, return "bogus" if the return type is a string. You
won't have the correct answer but you should have the gray and green boxes.
- Do you have a return statement? Your function should end with a return
statement, not a print statement. Do you have a return at the end of the
function? Maybe you have an if with return statements but not one at the very
end just in case one of the other cases don't match. Put a return at the
end of your function (that is not inside an if or for) with a value you don't
expect to return such as return "bogus" if you are suppose to return a
string.
If you are suppose to return an int, then return -785673 or some number you
really shouldn't get.
- Do you have the correct type of value to return? If the function is
suppose to return an integer, are you returning an integer?
- Strongly advise that you add in a "if main" statement below your
function definition and call that function with a test case.
if __name__ == '__main__':
compute("this is a test") # Call your function here with an example
But be careful if you just put this:
if __name__ == '__main__':
with no statement in the body of main, that can hang the APT tester and not
show you any output. In fact you should not have any function definitions
with 0 lines of code in the body.
You can always use the pass command which does nothing but is
a placeholder statement until you are ready to add a call to your
function, like this:
if __name__ == '__main__':
pass
- If you get the error nocompile, that could mean one of two things:
- You could have a main or a function with no code in its body such as
the suggestion above suggests
- You could have a syntax error in your code. Look at your code in
Pycharm. Are there any red lines on the right hand side or red squiggly
marks in your code? Is there a red
exclamation point in the top right corner of PyCharm indicating a syntax
error, such as you forget a : at the end of a for statement or an if
statement, or some other syntax error.
You must fix all syntax errors before uploading your file to run it on the APT tester.
- 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? Note it may show up for each sample
input it runs on. If it does show up, try adding in other print statements
to see if they show up.
- Did you accidentally type in extra letters in your file?
- If your output looks exactly like the output is suppose to but is GRAY
instead of GREEN, then you
may have an extra blank that doesn't show up. The string "frog" and "frog "
are different, the first is of length 4 and the second is of length 5.
If the string you are returning is the variable answer, instead return the
string "X"+answer+"X". You won't have the correct answer, so you will get
all grays, but you might notice extra blanks on either or both ends of your
answer.
- If you are getting gray and green boxes 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')
-
If you don't know where to start. Try the 7 steps! Step 1: Work a simple example by
hand. Then think about what you did... how did you solve it. Did you
iterate over words in a list, over characters in a string, etc. What did
you keep track of? How does the data need to be stored? In a list?
something else?