Python
1: Print Function
2: Escape Sequence
3: Comments
4: Escape Sequence as Normal Text
5: Print Emoji
6: Python as Calculator
7: Strings Concatenation
8: Input
9: int function
10: Variables
11: String Formatting
12: String Indexing
13: String Slicing
14: Step Argument
15: Some useful function and methods
16: Strip Method
17: Find and Replace method
18: Center method
19: If Statement
20: If else statement
21: Nested if-else Statement
22: if-elif-else statement
23: while loop
23.1: Example 1 while loop
23.2: Example 2 while loop
23.3: Example 3 while loop
24: Infinite loop
25: for loop
25.1: Example 1 for loop
26: break and continue statement
27: for loop with string
2: Escape Sequence
3: Comments
4: Escape Sequence as Normal Text
5: Print Emoji
6: Python as Calculator
7: Strings Concatenation
8: Input
9: int function
10: Variables
11: String Formatting
12: String Indexing
13: String Slicing
14: Step Argument
15: Some useful function and methods
16: Strip Method
17: Find and Replace method
18: Center method
19: If Statement
20: If else statement
21: Nested if-else Statement
22: if-elif-else statement
23: while loop
23.1: Example 1 while loop
23.2: Example 2 while loop
23.3: Example 3 while loop
24: Infinite loop
25: for loop
25.1: Example 1 for loop
26: break and continue statement
27: for loop with string
Chapter 6: Python as Calculator
In Python, int(integer) and float are data types.
Integer: numbers without decimal point.
Float: numbers with decimal points.
Operators | Description | Example |
+ | Addition | print(2+3) >>> 5 |
- | Subtraction | print(2-3) >>> -1 |
* | Multiplication | print(2*3) >>> 6 |
/ | Float Division | print(4/2) >>> 2.0 print(2/4) >>> 0.5 |
// | Integer Division | print(4//2) >>> 2 print(2/4) >>> 0 |
% | Modulo gives reminder | print(6%2) >>> 0 |
** | Exponent | print(2**3) >>> 8 |
print(2+5) # Addition
Output: 7
print(4/2) # Float Division
Output: 2.0
print(4//2) # Integer Division
Output: 2
print(2**4) # Exponent
Output: 16
print(2**0.5) # Finding square root of number
Output: 1.4142135623730951
print(round(2**0.5,3) # Finding square root of number upto 3 digits
Output: 1.414
print((6*3)*3/4*9%5) # BODMAS rule
Output: 1.5
print(7*5-8/6+98/2*5%3) # BODMAS rule
Output: 35.666666666666664