0% found this document useful (0 votes)
5 views

Python Practice Test Feedback

The document provides feedback on a Python practice test, highlighting common mistakes such as indentation errors, forgetting to return results, and incorrect use of input functions. It emphasizes the importance of defining function parameters, printing results for verification, and using the correct range in loops. Additionally, it outlines the marking scheme and encourages students to avoid these common pitfalls in their coding assignments.

Uploaded by

irfan141
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Python Practice Test Feedback

The document provides feedback on a Python practice test, highlighting common mistakes such as indentation errors, forgetting to return results, and incorrect use of input functions. It emphasizes the importance of defining function parameters, printing results for verification, and using the correct range in loops. Additionally, it outlines the marking scheme and encourages students to avoid these common pitfalls in their coding assignments.

Uploaded by

irfan141
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Python Practice Test Feedback

In the IT sessions, the TAs will also go through the questions and provide additional
feedback to you if needed.
The correct answer for the 1st question (for example):

def multiply_numbers(a,b,c):

answer= a*b*c
return answer

print("the answer of multiply_numbers(1,2,3) is", multiply_numbers(1,2,3))

1. We don't define the default values for a,b,c. This will allow us to have a flexible function.
Whatever we call the function, this function can return the correct answer.

2. Indentation error. Python is very sensitive to the indentation. If this is not correct, the
code cannot run.

def multiply_numbers(a,b,c):
"""insert the code that performs the operation.
Use the variable 'number' to hold and return the value """
# YOUR CODE HERE
a=1
b=2
c=3
result=multiply_numbers (a,b,c)
" Check your code here "
" Assign random input variables and check the answer"
" For example:"

print("the answer of multiply_numbers(1,2,3) is", multiply_numbers(1,2,3))

3. Forget to “return” the results. In the Python function, you need to return your calculated
values. For example, in Q1, you need to type “Return number”

4. Always print the results so that you know if it is done correctly. The print command
should be similar with my example.

5. When we call a Python function, we will give the function some input values directly,
instead of prompting a command like "input ()" here. If you do this again in the Python
coursework, you will get ZERO mark, unfortunately. The autograder will not understand
the "input()"

def multiply_numbers():
a = int(input("Enter first integer:"))
b = int(input("Enter second integer:"))
c = int(input("Enter third integer:"))
number = a * b * c
print("The product of " + str(a) + ", " + str(b) + " and " + str(c) + "
is " + str(number))
return
multiply_numbers()

6. An example of our marking scheme, as you can see, we are trying to call the function
with different input values, if they are all correct, you will get the full mark.

# Don't write code in this line

### BEGIN HIDDEN TESTS

assert multiply_numbers(3,4,5) == 60

assert multiply_numbers(2,2,2) == 8

assert multiply_numbers(-2,1,1) == -2
### END HIDDEN TESTS

7. Q4, most of the common mistake is from the usage of range(), as you know, range (n)
will give you the value from 0 to n-1. For instance, range(5) gives you 0,1,2,3,4. Therefore,
you should use range(n+1) instead of range(n).

for i in range(n):
e += (1**i) / math.factorial(i)

Here we found some common mistakes:

1. Removed the definition of functions. This is wrong, because the autograder


needs to call the function and give inputs to it, then it checks if the output is
correct.

2. We don't define the default values for a, b, c. This will allow us to have a flexible
function. Whatever we call the function, this function can return the correct
answer.

3. Indentation error. Python is very sensitive to the indentation. If this is not


correct, the code cannot run.

4. Forget to “return” the results. In the Python function, you need to return your
calculated values. For example, in Q1, you need to type “Return number”

5. Always print the results so that you know if it is done correctly. The print
command should be similar with my example.

6. When we call a Python function, we will give the function some input values
directly, instead of prompting a command like "input ()" here. If you do this again
in the Python coursework, you will get ZERO mark, unfortunately. The autograder
will not understand the "input()"

7. An example of our marking scheme, as you can see, we are trying to call the
function with different input values, if they are all correct, you will get the full
mark.

8. Q4, most of the common mistake is from using range(), as you know, range (n)
will give you the value from 0 to n-1. For instance, range(5) gives you 0,1,2,3,4.
Therefore, you should use range(n+1) instead of range(n).

Also, I am attaching the common mistakes in the file, please check and avoid such
mistakes again.

9. Q5, the most common mistake is the wrong expression of the position. Some
students forgot ‘s0’.

You might also like