# How 30 Days of Python Explains Python Variables and Built-in Functions

> Discover how 30 Days of Python explains Python variables and built-in functions with REPL examples, naming conventions, and practical exercises for print, len, and type.

- Repository: [Asabeneh/30-Days-Of-Python](https://github.com/Asabeneh/30-Days-Of-Python)
- Tags: tutorial
- Published: 2026-03-06

---

**The 30 Days of Python repository introduces Python variables and built-in functions in Day 2 through interactive REPL examples, strict naming conventions, and practical exercises covering essential functions like `print()`, `len()`, and `type()`.**

The Asabeneh/30-Days-Of-Python curriculum is an open-source, hands-on guide designed to take beginners from zero to proficiency. In the Day 2 lesson located at [`02_Day_Variables_builtin_functions/02_variables_builtin_functions.md`](https://github.com/Asabeneh/30-Days-Of-Python/blob/main/02_Day_Variables_builtin_functions/02_variables_builtin_functions.md), the course explains Python variables and built-in functions by combining immediate code execution with clear rules for identifier syntax and data manipulation.

## Built-in Functions Overview

The Day 2 tutorial treats built-in functions as global utilities that require no import statements. According to the source code, these functions are always available in the Python interpreter and provide immediate utility for common programming tasks.

### Essential Functions Covered

The lesson catalogs the most frequently used built-ins and demonstrates them within the Python REPL. The key functions include:

- **`print()`** – Outputs any number of arguments to the console, automatically inserting spaces between them.
- **`len()`** – Returns the length of strings, lists, or other iterables.
- **`type()`** – Reveals the class type of any object in memory.
- **`input()`** – Captures user data from the console as a string.
- **Casting utilities** – `int()`, `float()`, `str()`, `list()`, and `dict()` for explicit type conversion.
- **Data processing** – `min()`, `max()`, `sum()`, and `sorted()` for mathematical and sequence operations.
- **Introspection** – `help()` and `dir()` for examining object documentation and attributes.
- **File I/O** – `open()` for reading and writing files.

### Interactive REPL Demonstrations

The tutorial emphasizes learning by execution. Screenshots of the interactive shell illustrate how `print()` accepts multiple arguments, how `len()` operates on different data structures, and how `type()` identifies object classes. This approach reinforces that these functions are intrinsic to Python and accessible from any scope.

## Python Variable Naming Rules and Conventions

Variables are introduced as named references to objects stored in memory. The [`02_variables_builtin_functions.md`](https://github.com/Asabeneh/30-Days-Of-Python/blob/main/02_variables_builtin_functions.md) file establishes strict syntactic rules that prevent runtime errors and improve code readability.

### Identifier Syntax Rules

The Day 2 lesson defines four critical constraints for valid variable names:

- **Start character** – Must begin with a letter (`a-z`, `A-Z`) or an underscore (`_`).
- **No leading digits** – Numbers cannot appear as the first character.
- **Allowed characters** – Only letters, digits (0-9), and underscores are permitted after the initial character.
- **Case-sensitivity** – Python distinguishes between `firstName` and `firstname`, treating them as distinct identifiers.

Valid examples include `first_name`, `_if`, and `year_2021`. Invalid examples that raise `SyntaxError` include `first-name` (hyphen not allowed) and `1num` (starts with digit).

### Snake_case Convention

The guide explicitly adopts **snake_case** as the preferred naming style for Python variables. This convention uses lowercase words separated by underscores (e.g., `first_name`, `last_name`, `country_name`) to maximize readability and align with PEP 8 standards taught throughout the 30-day curriculum.

## Variable Declaration and Assignment Patterns

The assignment operator `=` binds values to identifiers without performing mathematical equality testing.

### Basic Assignment

A standard declaration follows the pattern `variable_name = value`. The tutorial provides concrete examples:

```python
first_name = 'Asabeneh'
last_name = 'Yetayeh'
age = 250
is_married = True

```

These statements store the respective objects in memory and bind them to the symbolic names on the left side.

### Multiple Assignment and Unpacking

The lesson demonstrates **parallel assignment** to declare multiple variables in a single line:

```python
first_name, last_name, country, age, is_married = \
    'Asabeneh', 'Yetayeh', 'Helsinki', 250, True

```

This syntax unpacks the tuple on the right into the variables on the left, enabling concise initialization of related data points.

### Capturing User Input

The `input()` function pauses execution to collect console data, always returning a **string** type:

```python
first_name = input('What is your name: ')
age = input('How old are you? ')

```

The tutorial emphasizes that arithmetic operations on `age` require explicit casting to `int()` or `float()` since `input()` does not perform automatic type conversion.

## Type Inspection and Casting

The Day 2 material pairs `type()` with casting functions to demonstrate Python's dynamic typing system. The `type()` function reveals an object's class, while `int()`, `float()`, and `str()` convert between representations:

```python
num_int = 10
num_float = float(num_int)   # 10.0

num_str = str(num_int)       # '10'

# Reverse conversion

value = '123.45'
as_float = float(value)
as_int = int(as_float)

```

These examples illustrate that concatenation requires string conversion, while mathematical operations demand numeric types.

## Summary

- The Day 2 lesson at [`02_Day_Variables_builtin_functions/02_variables_builtin_functions.md`](https://github.com/Asabeneh/30-Days-Of-Python/blob/main/02_Day_Variables_builtin_functions/02_variables_builtin_functions.md) covers **15+ built-in functions** including `print()`, `len()`, `type()`, and `input()`.
- **Variable naming** must start with a letter or underscore, cannot use hyphens, and is case-sensitive.
- The repository advocates **snake_case** (`first_name`) for all variable identifiers to ensure readability.
- **Multiple assignment** syntax allows parallel unpacking of values in a single line.
- The `input()` function always returns a **string**, requiring explicit casting with `int()` or `float()` for numeric operations.
- **Type inspection** via `type()` and casting via `str()`, `int()`, and `float()` enable safe data manipulation between types.

## Frequently Asked Questions

### What built-in functions does 30 Days of Python cover on Day 2?

The Day 2 tutorial covers essential built-ins including `print()`, `len()`, `type()`, `input()`, `int()`, `float()`, `str()`, `list()`, `dict()`, `min()`, `max()`, `sum()`, `sorted()`, `open()`, `help()`, and `dir()`. These are presented as global utilities available without import statements.

### What are the variable naming rules according to the 30 Days of Python guide?

According to the source material, valid variable names must start with a letter or underscore, cannot begin with a digit, and may contain only letters, digits, and underscores. The guide prohibits hyphens and emphasizes case-sensitivity, meaning `Name` and `name` reference different objects.

### How does the 30 Days of Python course teach type casting?

The lesson explains type casting through paired examples using `type()` for inspection and conversion functions like `int()`, `float()`, and `str()` for transformation. It demonstrates converting user input strings to integers for arithmetic and converting numbers to strings for concatenation.

### Where can I find the exercise files for Day 2 variables and built-in functions?

The primary documentation resides in [`02_Day_Variables_builtin_functions/02_variables_builtin_functions.md`](https://github.com/Asabeneh/30-Days-Of-Python/blob/main/02_Day_Variables_builtin_functions/02_variables_builtin_functions.md). Practical starter scripts and exercises are located in the `02_Day_Variables_builtin_functions/` directory, with additional context appearing in later modules like [`12_Day_Modules/mymodule.py`](https://github.com/Asabeneh/30-Days-Of-Python/blob/main/12_Day_Modules/mymodule.py) that demonstrate how variables organize into reusable components.