Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are grading an arithmetic quiz. The quiz asks a student for the sum of the n

ID: 3578756 • Letter: Y

Question

You are grading an arithmetic quiz. The quiz asks a student for the sum of the numbers.Determine if the student taking the quiz got the question correctInput The first and the only line of input contains a string of the form:a + b = c t is guaranteed that a, b, and c are single-digit positive integers. The input line will have exactly 9 characters formatted exactly as shown, with a single space separating each number and arithmetic operator

Output Print, on a single line, YES if the sum is correct; otherwise, print NO.

Explanation / Answer

def quiz(s):
    a = int(s[0])
    b = int(s[4])
    c = int(s[-1])
    if a+b == c:
        return "YES"
    else:
        return "NO"

s1 = "2 + 3 = 5"
print quiz(s1)
s2 = "2 + 3 = 6"
print quiz(s2)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote