Skip to content

Commit d0b806f

Browse files
create files for day-6
Signed-off-by: Abhishek Veeramalla <abhishek.veeramalla@gmail.com>
1 parent 0986fee commit d0b806f

15 files changed

+373
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Arithmetic Operations in Python
2+
3+
## Introduction
4+
5+
Arithmetic operators in Python allow you to perform basic mathematical calculations on numeric values. These operators include addition, subtraction, multiplication, division, and more.
6+
7+
## List of Arithmetic Operators
8+
9+
1. **Addition (+):** Adds two numbers.
10+
2. **Subtraction (-):** Subtracts the right operand from the left operand.
11+
3. **Multiplication (*):** Multiplies two numbers.
12+
4. **Division (/):** Divides the left operand by the right operand (results in a floating-point number).
13+
5. **Floor Division (//):** Divides the left operand by the right operand and rounds down to the nearest whole number.
14+
6. **Modulus (%):** Returns the remainder of the division of the left operand by the right operand.
15+
7. **Exponentiation (**):** Raises the left operand to the power of the right operand.
16+
17+
## Examples
18+
19+
### Addition
20+
21+
```python
22+
a = 5
23+
b = 3
24+
result = a + b
25+
print(result) # Output: 8
26+
```
27+
28+
### Subtraction
29+
30+
```python
31+
x = 10
32+
y = 7
33+
result = x - y
34+
print(result) # Output: 3
35+
```
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Assignment Operations in Python
2+
3+
## Introduction
4+
5+
Assignment operators in Python are used to assign values to variables. They include the basic assignment operator (=) and various compound assignment operators that perform an operation on the variable while assigning a value.
6+
7+
## List of Assignment Operators
8+
9+
1. **Basic Assignment (=):** Assigns a value to a variable.
10+
11+
2. **Addition Assignment (+=):** Adds the right operand to the left operand and assigns the result to the left operand.
12+
13+
3. **Subtraction Assignment (-=):** Subtracts the right operand from the left operand and assigns the result to the left operand.
14+
15+
4. **Multiplication Assignment (*=):** Multiplies the left operand by the right operand and assigns the result to the left operand.
16+
17+
5. **Division Assignment (/=):** Divides the left operand by the right operand and assigns the result to the left operand.
18+
19+
6. **Floor Division Assignment (//=):** Performs floor division on the left operand and assigns the result to the left operand.
20+
21+
7. **Modulus Assignment (%=):** Calculates the modulus of the left operand and assigns the result to the left operand.
22+
23+
8. **Exponentiation Assignment (**=):** Raises the left operand to the power of the right operand and assigns the result to the left operand.
24+
25+
## Examples
26+
27+
### Basic Assignment
28+
29+
```python
30+
x = 5
31+
```
32+
33+
### Addition Assignment
34+
35+
```python
36+
y = 10
37+
y += 3 # Equivalent to y = y + 3
38+
```

Day-06/01-Notes/Bitwise Operators.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Bitwise Operations in Python
2+
3+
## Introduction
4+
5+
Bitwise operators in Python are used to perform operations on individual bits of binary numbers. These operators include bitwise AND, OR, XOR, and more.
6+
7+
## List of Bitwise Operators
8+
9+
1. **Bitwise AND (&):** Performs a bitwise AND operation on the binary representations of the operands.
10+
2. **Bitwise OR (|):** Performs a bitwise OR operation.
11+
3. **Bitwise XOR (^):** Performs a bitwise XOR operation.
12+
4. **Bitwise NOT (~):** Flips the bits of the operand, changing 0 to 1 and 1 to 0.
13+
5. **Left Shift (<<):** Shifts the bits to the left by a specified number of positions.
14+
6. **Right Shift (>>):** Shifts the bits to the right.
15+
16+
## Examples
17+
18+
### Bitwise AND
19+
20+
```python
21+
a = 5 # Binary: 0101
22+
b = 3 # Binary: 0011
23+
result = a & b # Result: 0001 (Decimal: 1)
24+
```
25+
26+
### Bitwise OR
27+
28+
```python
29+
x = 10 # Binary: 1010
30+
y = 7 # Binary: 0111
31+
result = x | y # Result: 1111 (Decimal: 15)
32+
```

Day-06/01-Notes/Identity Operators.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Identity Operations in Python
2+
3+
## Introduction
4+
5+
Identity operators in Python are used to compare the memory locations of two objects to determine if they are the same object or not. The two identity operators are "is" and "is not."
6+
7+
## List of Identity Operators
8+
9+
1. **is:** Returns `True` if both operands refer to the same object.
10+
2. **is not:** Returns `True` if both operands refer to different objects.
11+
12+
### Examples
13+
14+
#### is Operator
15+
16+
```python
17+
x = [1, 2, 3]
18+
y = x # y now refers to the same object as x
19+
result = x is y
20+
# result will be True
21+
```
22+
23+
#### is not Operator
24+
25+
```python
26+
a = "hello"
27+
b = "world"
28+
result = a is not b
29+
# result will be True
30+
```

Day-06/01-Notes/Logical Operators.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Logical Operations in Python
2+
3+
## Introduction
4+
5+
Logical operators in Python are used to manipulate and combine Boolean values. These operators allow you to perform logical operations such as AND, OR, and NOT.
6+
7+
## List of Logical Operators
8+
9+
1. **AND (and):** Returns `True` if both operands are `True`.
10+
2. **OR (or):** Returns `True` if at least one of the operands is `True`.
11+
3. **NOT (not):** Returns the opposite Boolean value of the operand.
12+
13+
## Examples
14+
15+
### AND Operator
16+
17+
```python
18+
x = True
19+
y = False
20+
result = x and y
21+
# result will be False
22+
```
23+
24+
### OR Operator
25+
26+
```python
27+
a = True
28+
b = False
29+
result = a or b
30+
# result will be True
31+
```
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Membership Operations in Python
2+
3+
## Introduction
4+
5+
Membership operators in Python are used to check whether a value is present in a sequence or collection, such as a list, tuple, or string. The membership operators are "in" and "not in."
6+
7+
## List of Membership Operators
8+
9+
1. **in:** Returns `True` if the left operand is found in the sequence on the right.
10+
2. **not in:** Returns `True` if the left operand is not found in the sequence on the right.
11+
12+
### Examples
13+
14+
#### in Operator
15+
16+
```python
17+
fruits = ["apple", "banana", "cherry"]
18+
result = "banana" in fruits
19+
# result will be True
20+
```
21+
22+
#### not in Operator
23+
24+
```python
25+
colors = ["red", "green", "blue"]
26+
result = "yellow" not in colors
27+
# result will be True
28+
```
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Precedence of Operations in Python
2+
3+
## Introduction
4+
5+
Precedence of operations in Python defines the order in which different types of operators are evaluated in an expression. Operators with higher precedence are evaluated first.
6+
7+
## Examples
8+
9+
### Arithmetic Precedence
10+
11+
```python
12+
result = 5 + 3 * 2
13+
# Multiplication has higher precedence, so result is 11, not 16
14+
```
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Relational Operations in Python
2+
3+
## Introduction
4+
5+
Relational operators in Python are used to compare two values and determine the relationship between them. These operators return a Boolean result, which is either `True` or `False`.
6+
7+
## List of Relational Operators
8+
9+
1. **Equal to (==):** Checks if two values are equal.
10+
11+
2. **Not equal to (!=):** Checks if two values are not equal.
12+
13+
3. **Greater than (>):** Checks if the left operand is greater than the right operand.
14+
15+
4. **Less than (<):** Checks if the left operand is less than the right operand.
16+
17+
5. **Greater than or equal to (>=):** Checks if the left operand is greater than or equal to the right operand.
18+
19+
6. **Less than or equal to (<=):** Checks if the left operand is less than or equal to the right operand.
20+
21+
## Examples
22+
23+
### Equal to
24+
25+
```python
26+
a = 5
27+
b = 5
28+
result = a == b
29+
# result will be True
30+
```
31+
32+
### Not equal to
33+
34+
```python
35+
x = 10
36+
y = 7
37+
result = x != y
38+
# result will be True
39+
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
a = 10
2+
b = 5
3+
4+
sum_result = a + b
5+
difference_result = a - b
6+
product_result = a * b
7+
quotient_result = a / b
8+
9+
print("Sum:", sum_result)
10+
print("Difference:", difference_result)
11+
print("Product:", product_result)
12+
print("Quotient:", quotient_result)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
a = 10
2+
b = 5
3+
4+
less_than = a < b
5+
greater_than = a > b
6+
less_than_or_equal = a <= b
7+
greater_than_or_equal = a >= b
8+
equal = a == b
9+
not_equal = a != b
10+
11+
print("a < b:", less_than)
12+
print("a > b:", greater_than)
13+
print("a <= b:", less_than_or_equal)
14+
print("a >= b:", greater_than_or_equal)
15+
print("a == b:", equal)
16+
print("a != b:", not_equal)

0 commit comments

Comments
 (0)