Skip to content

Commit 98356cb

Browse files
add docs for day-2
1 parent 01141da commit 98356cb

File tree

5 files changed

+67
-0
lines changed

5 files changed

+67
-0
lines changed

Day-02/01-data-types.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Data Types
2+
3+
In programming, a data type is a classification or categorization that specifies which type of value a variable can hold. Data types are essential because they determine how data is stored in memory and what operations can be performed on that data. Python, like many programming languages, supports several built-in data types. Here are some of the common data types in Python:
4+
5+
1. **Numeric Data Types:**
6+
- **int**: Represents integers (whole numbers). Example: `x = 5`
7+
- **float**: Represents floating-point numbers (numbers with decimal points). Example: `y = 3.14`
8+
- **complex**: Represents complex numbers. Example: `z = 2 + 3j`
9+
10+
2. **Sequence Types:**
11+
- **str**: Represents strings (sequences of characters). Example: `text = "Hello, World"`
12+
- **list**: Represents lists (ordered, mutable sequences). Example: `my_list = [1, 2, 3]`
13+
- **tuple**: Represents tuples (ordered, immutable sequences). Example: `my_tuple = (1, 2, 3)`
14+
15+
3. **Mapping Type:**
16+
- **dict**: Represents dictionaries (key-value pairs). Example: `my_dict = {'name': 'John', 'age': 30}`
17+
18+
4. **Set Types:**
19+
- **set**: Represents sets (unordered collections of unique elements). Example: `my_set = {1, 2, 3}`
20+
- **frozenset**: Represents immutable sets. Example: `my_frozenset = frozenset([1, 2, 3])`
21+
22+
5. **Boolean Type:**
23+
- **bool**: Represents Boolean values (`True` or `False`). Example: `is_valid = True`
24+
25+
6. **Binary Types:**
26+
- **bytes**: Represents immutable sequences of bytes. Example: `data = b'Hello'`
27+
- **bytearray**: Represents mutable sequences of bytes. Example: `data = bytearray(b'Hello')`
28+
29+
7. **None Type:**
30+
- **NoneType**: Represents the `None` object, which is used to indicate the absence of a value or a null value.
31+
32+
8. **Custom Data Types:**
33+
- You can also define your custom data types using classes and objects.

Day-02/02-strings.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Strings
2+
3+
**1. String Data Type in Python:**
4+
5+
- In Python, a string is a sequence of characters, enclosed within single (' '), double (" "), or triple (''' ''' or """ """) quotes.
6+
- Strings are immutable, meaning you cannot change the characters within a string directly. Instead, you create new strings.
7+
- You can access individual characters in a string using indexing, e.g., `my_string[0]` will give you the first character.
8+
- Strings support various built-in methods, such as `len()`, `upper()`, `lower()`, `strip()`, `replace()`, and more, for manipulation.
9+
10+
**2. String Manipulation and Formatting:**
11+
12+
- Concatenation: You can combine strings using the `+` operator.
13+
- Substrings: Use slicing to extract portions of a string, e.g., `my_string[2:5]` will extract characters from the 2nd to the 4th position.
14+
- String interpolation: Python supports various ways to format strings, including f-strings (f"...{variable}..."), %-formatting ("%s %d" % ("string", 42)), and `str.format()`.
15+
- Escape sequences: Special characters like newline (\n), tab (\t), and others are represented using escape sequences.
16+
- String methods: Python provides many built-in methods for string manipulation, such as `split()`, `join()`, and `startswith()`.

Day-02/03-numeric.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Numberic Data Type
2+
3+
**1. Numeric Data Types in Python (int, float):**
4+
5+
- Python supports two primary numeric data types: `int` for integers and `float` for floating-point numbers.
6+
- Integers are whole numbers, and floats can represent both whole and fractional numbers.
7+
- You can perform arithmetic operations on these types, including addition, subtraction, multiplication, division, and more.
8+
- Be aware of potential issues with floating-point precision, which can lead to small inaccuracies in calculations.
9+
- Python also provides built-in functions for mathematical operations, such as `abs()`, `round()`, and `math` module for advanced functions.

Day-02/04-regex.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Regex
2+
3+
**1. Regular Expressions for Text Processing:**
4+
5+
- Regular expressions (regex or regexp) are a powerful tool for pattern matching and text processing.
6+
- The `re` module in Python is used for working with regular expressions.
7+
- Common metacharacters: `.` (any character), `*` (zero or more), `+` (one or more), `?` (zero or one), `[]` (character class), `|` (OR), `^` (start of a line), `$` (end of a line), etc.
8+
- Examples of regex usage: matching emails, phone numbers, or extracting data from text.
9+
- `re` module functions include `re.match()`, `re.search()`, `re.findall()`, and `re.sub()` for pattern matching and replacement.

Day-02/strings.py

Whitespace-only changes.

0 commit comments

Comments
 (0)