Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.0 kB
1
Indexable
Never
#Past Exam v1 question

keepGoing = True
while keepGoing == True:
    first = int(input('Enter 1st operand: '))
    second = int(input('Enter 2nd operand: '))
    addition = int(input('What is ' + str(first) + ' + ' + str(second) + '? '))
    addAns = first + second
    if addition == addAns:
        print('Correct!')
    else:
        print('Your answer is wrong.')
    subtraction = int(input('What is ' + str(first) + ' - ' + str(second) + '? '))
    subAns = first - second
    if subtraction == subAns:
        print('Correct!')
    else:
        print('Your answer is wrong.')
    multiply = int(input('What is ' + str(first) + ' * ' + str(second) + '? '))
    mulAns = first * second
    if multiply == mulAns:
        print('Correct!')
    else:
        print('Your answer is wrong.')
    keepGoing = input('Do you want to continue(y/n)? ')
    if keepGoing == 'y':
        keepGoing = True
    if keepGoing == 'n':
        keepGoing = False
print('Bye!')