You are grading an arithmetic quiz. The quiz asks a student for the sum of the n
ID: 3580756 • 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)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.