Day 2: Mastering Python Variables & Data Types | 30-Day Python Challenge

preview_player
Показать описание
Welcome to Day 2 of the 30-Day Python Challenge! In this video, we dive into the fundamentals of Python variables and data types, including integers, floats, strings, and booleans. You'll also learn how to perform type conversion between these data types. By the end of this lesson, you'll have a solid foundation for managing and manipulating data in Python.

Stay tuned for Day 3, where we'll explore more advanced concepts!

### 1. String
- str: A sequence of characters used to represent text.
```python
name = "Alice" # String
```

### 2. Numeric Types
- int: Integer values without a decimal point.
```python
age = 25 # Integer
```
- float: Floating-point numbers that contain a decimal point.
```python
height = 5.9 # Float
```

### 3. Boolean
- bool: Represents a value of either True or False.
```python
is_valid = True # Boolean
```

### 4. Other Data Types
- complex: Complex numbers with real and imaginary parts.
```python
z = 3 + 4j # Complex number
```
- list: Mutable ordered sequences of items.
```python
fruits = ["apple", "banana", "cherry"] # List
```
- tuple: Immutable ordered sequences of items.
```python
coordinates = (10.0, 20.0) # Tuple
```
- dict: Collection of key-value pairs.
```python
person = {"name": "Bob", "age": 30} # Dictionary
```
- set: Unordered collections of unique items.
```python
unique_numbers = {1, 2, 3, 4, 5} # Set
```
- frozenset: Immutable version of a set.
```python
immutable_set = frozenset([1, 2, 3]) # Frozenset
```
- NoneType: Represents the absence of a value.
```python
result = None # NoneType
```

### Example Usage:
We’ll walk through examples of each data type, demonstrating how to declare and utilize them in your code.

```python
# String
name = "Alice" # str

# Numeric types
age = 25 # int
height = 5.9 # float

# Boolean
is_valid = True # bool

# Other data types
z = 3 + 4j # complex
fruits = ["apple", "banana", "cherry"] # list
coordinates = (10.0, 20.0) # tuple
person = {"name": "Bob", "age": 30} # dict
unique_numbers = {1, 2, 3, 4, 5} # set
immutable_set = frozenset([1, 2, 3]) # frozenset
result = None # NoneType
```

Join us as we dive into the world of Python data types! Don’t forget to like, share, and subscribe for more programming tutorials. If you have any questions or topics you'd like us to cover, leave a comment below!

Join this channel to get access to perks:

#thecodingbus #python
Рекомендации по теме