Skip to main content

Posts

Showing posts with the label multiply

Simple Calculator using Python

# Standard Calculator operator = input('Which operation do you wanna perform? \n +, -, * or /:  ') a = float(input('enter the number here:')) b = float(input('enter the number here:')) if operator == '+':     print(a, operator, b, '=', a+b) elif operator == '-':     print(a, operator, b, '=', a-b) elif operator == '*':     print(a, operator, b, '=', a*b) elif operator == '/':     print(a, operator, b, '=', a/b) else:     print('Invalid operation!') # Output : For Addition: Which operation do you wanna perform?   +, -, * or /:  + enter the number here:33 enter the number here:2.036 33.0 + 2.036 = 35.036 For Subtraction: Which operation do you wanna perform?   +, -, * or /:  - enter the number here:23 enter the number here:65656 23.0 - 65656.0 = -65633.0 For Multiplication: Which operation do you wanna perform?   +, -, * or /:  * enter the number here:1.009 enter the number here:23187 1.009 *

Arithmetic Operators in python

>> Arithmetic operators + (Addition) - (Subtraction) * (Multiplication) / (Division) // (Floor Division) % (Modulus) ** (Exponent). >> Other operators are Comparison, Assignment and Logical which are most widely used. 1) Adding two variables:  a = 12 b = 231 add = a + b print('The addition is:', add) #Output: The addition is: 243 2) Subtracting two variables: a = 12 b = 231 subtract = b - a print('The subtraction is:', subtract) #Output: The subtraction is: 219 3) Multipling two variables: a = 12 b = 231 multiplication = a * b print('The multiplication is:', multiplication) #Output: The multiplication is: 2772 4) Dividing two variables: a = 12 b = 231 division = b/a print('The division is:', division) #Output: The division is: 19.25 5) Floor division: a = 12 b = 231 floor_division = b//a print('The floor division is:', floor_division) #Output: The floor division is: 19 6) Modulus: a = 12 b = 231 modulus = b % a print('The modulus