|
| 1 | +import sys |
| 2 | +import time |
| 3 | + |
| 4 | +decore = "===============================" |
| 5 | +byetext = "\n\nThank you For Using Our Program\n\nExiting..." |
| 6 | +print(decore) |
| 7 | +print("\nWelcome To PyCalc Project: CLI Edition\n") |
| 8 | +print(decore) |
| 9 | +time.sleep(0.2) |
| 10 | +print("\nVersion:5.0\n") |
| 11 | +print("Branch: Bêta") |
| 12 | +print(decore) |
| 13 | +print("Copyright © 2021 TechVio") |
| 14 | +time.sleep(0.5) |
| 15 | +print(decore) |
| 16 | +print("Project Link: https://www.github.com/techvio1/PyCalc-Project/") |
| 17 | +print(decore) |
| 18 | +time.sleep(1) |
| 19 | +print("License: MIT License: https://mit-license.org/") |
| 20 | +print(decore) |
| 21 | +time.sleep(0.2) |
| 22 | +print("running...") |
| 23 | + |
| 24 | + |
| 25 | +def calc(): |
| 26 | + time.sleep(1.0) |
| 27 | + print(decore) |
| 28 | + num1 = float(input("Enter Your First Number: ")) |
| 29 | + print(decore) |
| 30 | + time.sleep(0.1) |
| 31 | + operation = input("Enter Your Operation: ") |
| 32 | + print(decore) |
| 33 | + time.sleep(0.1) |
| 34 | + num2 = float(input("Enter Your Second Number:")) |
| 35 | + print(decore) |
| 36 | + time.sleep(0.1) |
| 37 | + if operation == "*": |
| 38 | + result = float(num1 * num2) |
| 39 | + print(result) |
| 40 | + time.sleep(0.5) |
| 41 | + request = input("Do you want to do another operation (y/n): ") |
| 42 | + if request == "y": |
| 43 | + print("Please Wait...") |
| 44 | + time.sleep(1.0) |
| 45 | + calc() |
| 46 | + else: |
| 47 | + console() |
| 48 | + elif operation == "+": |
| 49 | + result = float(num1 + num2) |
| 50 | + print(result) |
| 51 | + time.sleep(0.5) |
| 52 | + request = input("Do you want to do another operation (y/n): ") |
| 53 | + if request == "y": |
| 54 | + print("Please Wait...") |
| 55 | + time.sleep(1.0) |
| 56 | + calc() |
| 57 | + else: |
| 58 | + console() |
| 59 | + elif operation == "-": |
| 60 | + result = float(num1 - num2) |
| 61 | + print(result) |
| 62 | + time.sleep(0.5) |
| 63 | + request = input("Do you want to do another operation (y/n): ") |
| 64 | + if request == "y": |
| 65 | + print("Please Wait...") |
| 66 | + time.sleep(1.0) |
| 67 | + calc() |
| 68 | + else: |
| 69 | + console() |
| 70 | + elif operation == "/": |
| 71 | + result = float(num1 / num2) |
| 72 | + print(result) |
| 73 | + time.sleep(0.5) |
| 74 | + request = input("Do you want to do another operation (y/n): ") |
| 75 | + if request == "y": |
| 76 | + print("Please Wait...") |
| 77 | + time.sleep(1.0) |
| 78 | + calc() |
| 79 | + else: |
| 80 | + console() |
| 81 | + elif operation == "%": |
| 82 | + result = float(num1 % num2) |
| 83 | + print(result) |
| 84 | + time.sleep(0.5) |
| 85 | + request = input("Do you want to do another operation (y/n): ") |
| 86 | + if request == "y": |
| 87 | + print("Please Wait...") |
| 88 | + time.sleep(1.0) |
| 89 | + calc() |
| 90 | + else: |
| 91 | + console() |
| 92 | + elif operation == "**": |
| 93 | + result = float(num1 ** num2) |
| 94 | + print(result) |
| 95 | + time.sleep(0.5) |
| 96 | + request = input("Do you want to do another operation (y/n): ") |
| 97 | + if request == "y": |
| 98 | + print("Please Wait...") |
| 99 | + time.sleep(1.0) |
| 100 | + calc() |
| 101 | + else: |
| 102 | + console() |
| 103 | + elif operation == "//": |
| 104 | + result = float(num1 // num2) |
| 105 | + print(result) |
| 106 | + time.sleep(0.5) |
| 107 | + request = input("Do you want to do another operation (y/n): ") |
| 108 | + if request == "y": |
| 109 | + print("Please Wait...") |
| 110 | + time.sleep(1.0) |
| 111 | + calc() |
| 112 | + else: |
| 113 | + console() |
| 114 | + else: |
| 115 | + time.sleep(0.5) |
| 116 | + print("Error: Incorrect Operation:") |
| 117 | + time.sleep(0.5) |
| 118 | + print("=====================") |
| 119 | + print("Addition: +") |
| 120 | + print("=====================") |
| 121 | + print("Subtraction: -") |
| 122 | + print("=====================") |
| 123 | + print("Multiplication: *") |
| 124 | + print("=====================") |
| 125 | + print("Division: /") |
| 126 | + print("=====================") |
| 127 | + print("Modulus: %") |
| 128 | + print("=====================") |
| 129 | + print("Exponentiation: **") |
| 130 | + print("=====================") |
| 131 | + print("Floor division: //") |
| 132 | + print("=====================") |
| 133 | + time.sleep(1.0) |
| 134 | + calc() |
| 135 | + |
| 136 | + |
| 137 | +def squareroot(): |
| 138 | + from math import sqrt |
| 139 | + num = float(input("Enter A Number: ")) |
| 140 | + result = sqrt(num) |
| 141 | + print(result) |
| 142 | + request = input("Do you want to do another square root operation ? (y/n/q): ") |
| 143 | + if request == 'y': |
| 144 | + squareroot() |
| 145 | + elif request == 'n': |
| 146 | + console() |
| 147 | + elif request == 'q': |
| 148 | + time.sleep(0.5) |
| 149 | + print(byetext) |
| 150 | + time.sleep(0.5) |
| 151 | + sys.exit() |
| 152 | + else: |
| 153 | + print("Incorrect Parameter, back to console") |
| 154 | + time.sleep(1.5) |
| 155 | + console() |
| 156 | + |
| 157 | + |
| 158 | +def console(): |
| 159 | + calculator_mode = input("Select Calculator Mode: ") |
| 160 | + if calculator_mode == "help": |
| 161 | + print(decore) |
| 162 | + print('square root mode: "sqrt"') |
| 163 | + print('normal Calculator Mode: "calc"') |
| 164 | + print('console version: "version"') |
| 165 | + print(decore) |
| 166 | + console() |
| 167 | + elif calculator_mode == "calc": |
| 168 | + calc() |
| 169 | + elif calculator_mode == "sqrt": |
| 170 | + squareroot() |
| 171 | + elif calculator_mode == "version": |
| 172 | + print("pycalc console v1.0 build 062621") |
| 173 | + console() |
| 174 | + elif calculator_mode == "exit": |
| 175 | + time.sleep(0.5) |
| 176 | + print(byetext) |
| 177 | + time.sleep(0.5) |
| 178 | + sys.exit() |
| 179 | + else: |
| 180 | + print(decore) |
| 181 | + print("Incorrect mode: Type 'help' for more information") |
| 182 | + print(decore) |
| 183 | + console() |
| 184 | + |
| 185 | + |
| 186 | +console() |
0 commit comments