Created
April 30, 2020 13:27
-
-
Save Raj39120/0ed24fbb8f4fc321fb6dff4c638659f7 to your computer and use it in GitHub Desktop.
Simple calculator using classes and user input
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
class Calculator: | |
def __init__(self, number_1, number_2): | |
self.number_1 = number_1 | |
self.number_2 = number_2 | |
print("The sum of the two numbers is: " + str(number_1+number_2)) | |
print("The difference of the two numbers is: " + str(number_1-number_2)) | |
print("The product of the two numbers is: " + str(number_1*number_2)) | |
print("The quotient of the two numbers is: " + str(float(number_1)/float(number_2))) | |
print("Number 1 squared is: " + str(number_1**2)) | |
print("Number 2 squared is: " + str(number_2**2)) | |
print("Number 1 cubed is: " + str(number_1**3)) | |
print("Number 2 cubed is: " + str(number_2**3)) | |
c1 = Calculator(input("Enter number 1 here: "), input("Enter number 2 here: ")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment