Case 1

mail@pastecode.io avatar
unknown
plain_text
2 years ago
2.0 kB
3
Indexable
Never
import os
os.system('clear')


print('**************************')
print('    MATHLETE CALCULATOR   ')
print('__________________________')
print('add | Add two numbers     ')
print('sub | Subtract two numbers')
print('mul | Multiply two numbers')
print('div | Divide two numbers  ')
print('__________________________')

selection = input('Selection: ')
print('__________________________')
print('Calculating "c" for expression:' )

a = 0
b = 0

while selection == 'add':
    print('                  ')
    print('    a + b = c     ')
    print('                  ')
    print('Please, enter values for "a" and "b"')
    print('                  ')
    a = int(input('a = '))
    b = int(input('b = '))
    add = a + b
    print('                  ')
    print('RESULT: ', a, '+', b, '=', add)

    if selection == 'sub':
        print('                  ')
        print('    a - b = c     ')
        print('                  ')
        print('Please, enter values for "a" and "b"')
        print('                  ')
        a = int(input('a = '))
        b = int(input('b = '))
        sub = a - b
        print('                  ')
        print('RESULT: ', a, '-', b, '=', sub)

    elif selection == 'mul':
        print('                  ')
        print('    a * b = c     ')
        print('                  ')
        print('Please, enter values for "a" and "b"')
        print('                  ')
        a = int(input('a = '))
        b = int(input('b = '))
        mul = a * b
        print('                  ')
        print('RESULT: ', a, '*', b, '=', mul)

    elif selection == 'div':
        print('                  ')
        print('    a / b = c     ')
        print('                  ')
        print('Please, enter values for "a" and "b"')
        print('                  ')
        a = int(input('a = '))
        b = int(input('b = '))
        div = a / b
        print('                  ')
        print('RESULT: ', a, '/', b, '=', div)
    input('Press enter to continue...')