ZDI2YTNhMzJjODE0NWNkMTQxNTI4ZTAwNDczZWQxMWVjNmM4OWNiMTMwMzg5MGYwZGIzZWVmMDYyYjhlM2FjMg.mu8c4a81.eyJ1cmwiOiIvcGwvY291cnNlX2luc3RhbmNlLzEvaW5zdGFuY2VfcXVlc3Rpb24vNjgvIiwiYXV0aG5fdXNlcl9pZCI6IjEifQ
Skip to main content Accessibility guide
PrairieLearn Go home
  • XC 101, SectionA
  • Assessments
  • Gradebook
  • C2
Load from disk
  • Dev User student
    View type
    ✓ Staff view staff ✓ Student view student ✓ Student view without access restrictions student
    Effective user
    Customize…
    Course Requests Settings Log out

Regenerate assessment instance

Warning: Regenerating the assessment instance will select a new set of questions from this assessment. Any progress on the current assessment instance will be lost.

Are you sure you want to regenerate the assessment instance?

Course staff: Regenerate your assessment instance to pick up changes to the assessment or to get a fresh set of questions.

C2.5. Autograder demo: Adding leading/trailing code

This question defines the files leading_code.py and trailing_code.py to automatically prepend/append code to the student's answer before grading. Adding these files allows one to automatically handle imports, function definitions, etc. The contents of the leading and trailing code files are displayed in the code blocks below.

Complete the function below that computes one iteration of gradient descent: $$ {\bf x}_{n+1} = {\bf x}_n - \alpha \nabla f\left({\bf x}_n\right) $$ Specifically, compute the value of x_new (${\bf x}_{n+1}$) given ${\bf x}_n$, $\alpha$, and $\nabla f\left({\bf x}_n\right)$.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
def f(x):
    return x**2


def df(x):
    return 2 * x


def gradient_descent(x, alpha):
    grad_f = df(x)
1
    return x_new

Correct answer

Collection 2

Assessment overview
Total points: 0/68
Score:
0%

Question C2.5

Value: 1
Total points: — /5
Auto-graded question

This form is only for reporting errors in the question itself. Do not use this form if you just don't know how to answer the question.

Previous question Next question

 Personal Notes

No attached notes

Attached files will be saved here for your reference. These files act as personal notes and can be used for your own review purposes. They are not used for grading.

Max file size: 10 MB

Attached personal notes will be saved here for your reference. These notes can be used for your own review purposes. They are not used for grading.

Staff information

Student details

Dev User
dev@example.com

Question

QID:
demo/autograder/python/leadingTrailing
Title:
Autograder demo: Adding leading/trailing code

Variant

Started at:
2026-09-19 06:59:24 (CDT)
Duration:
0s
Show/Hide answer
{}

Assessment instance

Assessment:
demo/externalGrading
Started at:
2026-09-18 22:13:44 (CDT)
Duration:
0s
View log
This box is not visible to students.