livepython.net

50. Fix and Tidy a Messy Python Program

HardComment out

Overview

Use everything from this chapter: read errors, comment out lines, and keep only true comments.

Problem Statement

The starter code should print a small report card, but it has a typo that stops it, two debug prints, and a comment that is wrong. Fix the typo, remove the debug output, correct the wrong comment, and make it print:

Report for Rocky
Marks: 450 out of 500
Percentage: 90.0

Input

No input is required for this question.

Output

Report for Rocky
Marks: 450 out of 500
Percentage: 90.0

Learn this firstChapter 6 · Commenting Out Code to Test and Debug
solution.py
student = "Rocky"
marks = 450
total_marks = 500  # the marks Rocky scored
print("debug: marks is", marks)
percentage = marks / total_mark * 100
print("debug: percentage is", percentage)
print("Report for", student)
print("Marks:", marks, "out of", total_marks)
print("Percentage:", percentage)

EXPECTED OUTPUT

1Report for Rocky
2Marks: 450 out of 500
3Percentage: 90.0

YOUR OUTPUT

Press Run to see your output here. Lines are compared with the expected output.