- Addition using operators
- Subtraction using operators
- Multiplication using operators
- Division using operators
- Exponents using operators
- Remainder using operators
- Square Root Calculator
Computing math calculations is very common in programming languages. Performing math calculations in Python is simple. Enter the following code into the notebook and press Shift+ Enter:
1) Addition using operators
#addition
sum = 2 + 4
print(sum)

2) Subtraction using operators
#subtraction
diff = 6 - 2
print(diff)

3) Multiplication using operators
#multiplication
product = 5 * 5
print(product)

4) Division using operators
#division
div = 20/4
print(div)

5) Exponents using operators
#exponents 2 to the power of 2
exponents = 2**2
print(exponents)

6) Remainder using operators
#Remainder of 10 divided by 3
remainder = 10%3
print(remainder)

7) Square Root Calculator
import math
#square root. This requires importing the math library
sq = math.sqrt(4)
print(sq)

- Python Lesson 1: Hello World in Python
- Python Lesson 2: Reserved Keywords
- Python Lesson 3: Creating Variables
- Python Lesson 4: Performing math calculations in Python using operators
- Python Lesson 5: Working with Strings
- Python Lesson 6: Useful String Methods
- Python Lesson 7: Getting User Keyboard input
- Python Lesson 8: Importing Modules into your Python code
- Python Lesson 9: Decision making in Python
- Python Lesson 10: Creating loops in Python
- Python Lesson 11: Lists in Python
- Python Lesson 12: Tuples in Python
- Python Lesson 13: Dictionaries in Python
- Python Lesson 14: Sets in Python
- Python Lesson 15: Dealing with dates and time
- Python Lesson 16: Creating and using functions
- Python Lesson 17: Creating and using classes in Python
- Python Lesson 18: List Comprehensions
- Python Lesson 19: Lambda Functions
- Python Lesson 20: Error Handling