Skip to content
Snippets Groups Projects
Commit 7dd86f25 authored by Jesson Yo's avatar Jesson Yo
Browse files

Merge branch 'feature/integration' into 'main'

[FEAT] added exception handling for driver program based on task 7

See merge request !8
parents 441673c8 eb91673c
Branches main
1 merge request!8[FEAT] added exception handling for driver program based on task 7
...@@ -7,31 +7,38 @@ from power import power ...@@ -7,31 +7,38 @@ from power import power
def main(): def main():
while True: while True:
print('Insert your first number: ', end='') try:
a = int(input()) print('Insert your first number: ', end='')
a = int(input())
print('Insert your second number: ', end='')
b = int(input()) print('Insert your second number: ', end='')
b = int(input())
print('Insert your operator (add/substract/division/multiplication/power): ', end='')
operator = input() print('Insert your operator (add/substract/division/multiplication/power): ', end='')
operator = input()
if operator == 'add':
answer = addition(a,b) if operator == 'add':
answer = addition(a,b)
elif operator == 'substract':
answer = subtract(a,b) elif operator == 'substract':
answer = subtract(a,b)
elif operator == 'division':
answer = division(a,b) elif operator == 'division':
answer = division(a,b)
elif operator == 'multiplication':
answer = multiplication(a,b) elif operator == 'multiplication':
answer = multiplication(a,b)
elif operator == 'power':
answer = power(a,b) elif operator == 'power':
answer = power(a,b)
print('The answer is', answer)
else:
print('Incorrect operator')
continue
print('The answer is', answer)
except Exception as error:
print(error)
if __name__ == '__main__': if __name__ == '__main__':
main() main()
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment