Write a function called "check_answer" which will determine if a given addition or subtraction problem was solved correctly. Here's the IPO notation for the function: =function: input: = check_answer two numbers (number1 & number2, both integers); an answer (an integer) and an operator (+ or -, expressed as a String) processing: determines if the supplied expression is correct, for example, if the operator is", number11. number22 and answer 3 then the expression is correct returns True if the expression is correct, False if it is not correct Here's a sample program that you can use to test your function: answer check answer (1, 2, 3, 4) print (answer1) answer2 check, answer (1. 2. -1.) print (answer2) answer3 check answer(9,5, 3, "") print (answer 3) answer4 check answer (8, 2, 4, print (answer4) And here's the expected output: True

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question
Part 4
Write a function called "check_answer" which will determine if a given addition or subtraction problem was solved
correctly. Here's the IPO notation for the function:
= function:
input:
= processing:
check_answer
two numbers (number1 & number2, both integers); an answer (an integer)
and an operator (+ or -, expressed as a String)
determines if the supplied expression is correct. for example, if the operator
is "+", number1= 1. number22 and answer 3 then the expression is correct
(1+2= 3).
= output: returns True if the expression is correct, False if it is not correct
Here's a sample program that you can use to test your function:
answerl=check_answer (1, 2, 3, 4)
print (answer1)
answer2=check_answer (1, 2, -1, -
print (answer2)
answer3=check_answer (9, 5, 3,
print (answer3)
answert check, answer (8, 2, 4.-)
print (answer)
And here's the expected output:
True
True
False
False
Transcribed Image Text:Part 4 Write a function called "check_answer" which will determine if a given addition or subtraction problem was solved correctly. Here's the IPO notation for the function: = function: input: = processing: check_answer two numbers (number1 & number2, both integers); an answer (an integer) and an operator (+ or -, expressed as a String) determines if the supplied expression is correct. for example, if the operator is "+", number1= 1. number22 and answer 3 then the expression is correct (1+2= 3). = output: returns True if the expression is correct, False if it is not correct Here's a sample program that you can use to test your function: answerl=check_answer (1, 2, 3, 4) print (answer1) answer2=check_answer (1, 2, -1, - print (answer2) answer3=check_answer (9, 5, 3, print (answer3) answert check, answer (8, 2, 4.-) print (answer) And here's the expected output: True True False False
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr