Created
September 16, 2020 21:08
-
-
Save oohwooh/e1d2c83b7add444cb2d46c1714683c27 to your computer and use it in GitHub Desktop.
My Second Calculator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# My second calculator | |
print('Calculator loading... please wait') | |
add = {i:{j:i+j for j in range(1000)} for i in range(1000)} | |
sub = {i:{j:i-j for j in range(1000)} for i in range(1000)} | |
mult = {i:{j:i*j for j in range(1000)} for i in range(1000)} | |
div = {i:{j:i/j for j in range(1,1000)} for i in range(1000)} | |
print(''' | |
Welcome to my calculator! | |
Please make a selection | |
a: Addition | |
s: Subtraction | |
m: Multiplication | |
d: Division''') | |
selection = input('a,s,m,d: ') | |
if selection == 'a': | |
operation = add | |
if selection == 's': | |
operation = sub | |
if selection == 'm': | |
operation = mult | |
if selection == 'd': | |
operation = div | |
first_number = input('please enter the first number') | |
second_number = input('please enter the second number') | |
print('Your result is:') | |
print(operation[int(first_number)][int(second_number)]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment