diff --git a/README.md b/README.md index 5d75dd92..8162eb75 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,6 @@ For example, if you wanna add a solution for problem 0001, you should do like th * cd `YOU_GITHUB_USER_NAME`. * mkdir `0001`. * cd `0001`. - * and the write some code & test it. + * and then write some code & test it. If all these steps done, send us an pull request. After we accept your request, we'll invite you to this group. diff --git a/noviicee/0001/calculator_advanced.py b/noviicee/0001/calculator_advanced.py new file mode 100644 index 00000000..5dfe2327 --- /dev/null +++ b/noviicee/0001/calculator_advanced.py @@ -0,0 +1,63 @@ +#advanced calculator +#a calculator with some more advanced features.. +#it will work until we exit the calculator + +import sys +#define functions for the advanced calculator- +def add(x,y): + return (x+y) + +def subtract(x,y): + return (x-y) + +def multiply(x,y): + return (x*y) + +def get_modulus(x,y): + return(x%y) + +def float_divide(x,y): + return (x/y) + +def floor_divide(x,y): + return(x//y) + +#take input from the user +while True: + choice=int(input("""Select Operation:\n + 1.Add + 2.Subtract + 3.Multiply + 4.Get the Remainder after division + 5.Divide + 6.Divide and get the integer value + 7. Exit\n\n""")) + if choice == 1: + num1 = int(input("Enter first number: \n")) + num2 = int(input("Enter second number: \n")) + print(num1,"+",num2,"=", add(num1,num2)) + elif choice == 2: + num1 = int(input("Enter first number: \n")) + num2 = int(input("Enter second number: \n")) + print(num1,"-",num2,"=", subtract(num1,num2)) + elif choice == 3: + num1 = int(input("Enter first number: \n")) + num2 = int(input("Enter second number: \n")) + print(num1,"*",num2,"=", multiply(num1,num2)) + elif choice == 4: + num1 = int(input("Enter first number: \n")) + num2 = int(input("Enter second number: \n")) + print(num1,"%",num2,"=", get_modulus(num1,num2)) + elif choice == 5: + num1 = int(input("Enter first number: \n")) + num2 = int(input("Enter second number: \n")) + print(num1,"/",num2,"=", float_divide(num1,num2)) + elif choice == 6: + num1 = int(input("Enter first number: \n")) + num2 = int(input("Enter second number: \n")) + print(num1,"//",num2,"=", floor_divide(num1,num2)) + elif choice==7: + sys.exit(0) + else: + print("Invalid input.") + print("Try Again...") diff --git a/noviicee/0001/result_output.txt b/noviicee/0001/result_output.txt new file mode 100644 index 00000000..b77d60f5 --- /dev/null +++ b/noviicee/0001/result_output.txt @@ -0,0 +1,136 @@ +TESTING$calculator_advanced.py +Select Operation: + + 1.Add + 2.Subtract + 3.Multiply + 4.Get the Remainder after division + 5.Divide + 6. Divide and get the integer value + 7. Exit + +1 +Enter first number: +12 +Enter second number: +32 +12 + 32 = 44 +Select Operation: + + 1.Add + 2.Subtract + 3.Multiply + 4.Get the Remainder after division + 5.Divide + 6. Divide and get the integer value + 7. Exit + +2 +Enter first number: +12 +Enter second number: +32 +12 - 32 = -20 +Select Operation: + + 1.Add + 2.Subtract + 3.Multiply + 4.Get the Remainder after division + 5.Divide + 6. Divide and get the integer value + 7. Exit + +3 +Enter first number: +12 +Enter second number: +32 +12 * 32 = 384 +Select Operation: + + 1.Add + 2.Subtract + 3.Multiply + 4.Get the Remainder after division + 5.Divide + 6. Divide and get the integer value + 7. Exit + +4 +Enter first number: +36 +Enter second number: +5 +36 % 5 = 1 +Select Operation: + + 1.Add + 2.Subtract + 3.Multiply + 4.Get the Remainder after division + 5.Divide + 6. Divide and get the integer value + 7. Exit + +5 +Enter first number: +78 +Enter second number: +4 +78 / 4 = 19.5 +Select Operation: + + 1.Add + 2.Subtract + 3.Multiply + 4.Get the Remainder after division + 5.Divide + 6. Divide and get the integer value + 7. Exit + +6 +Enter first number: +78 +Enter second number: +4 +78 // 4 = 19 +Select Operation: + + 1.Add + 2.Subtract + 3.Multiply + 4.Get the Remainder after division + 5.Divide + 6. Divide and get the integer value + 7. Exit + +12 +Invalid input. +Try Again... +Select Operation: + + 1.Add + 2.Subtract + 3.Multiply + 4.Get the Remainder after division + 5.Divide + 6. Divide and get the integer value + 7. Exit + +233 +Invalid input. +Try Again... +Select Operation: + + 1.Add + 2.Subtract + 3.Multiply + 4.Get the Remainder after division + 5.Divide + 6. Divide and get the integer value + 7. Exit + +7 + +TESTING$calculator_advanced.py \ No newline at end of file