This repository contains a structured collection of Python code examples and explanations, specifically designed for learning Python fundamentals and special functions. It provides foundational knowledge required for diving into Machine Learning (ML) and data science, covering basic Python programming to more advanced topics such as functions, comprehensions, and modules.
The content is divided into multiple sections, each focused on a specific concept that is frequently used in Python programming and ML workflows. Whether you're a beginner or preparing to get into ML, this repository is a comprehensive guide to mastering Python basics and essential functions.
- Basics of Python
- Strings in Python
- Booleans in Python
- User Input Handling
- Data Structures
- Functions
- Special Functions
- Comprehensions
- Modules and Packages
This section introduces basic Python syntax and concepts such as function declaration, function calling, loops, and conditionals. These concepts are essential for structuring any Python code, including ML models.
01_basics.py
: Introduction to functions and function calling.02_strings.py
: String operations, slicing, and string manipulation.03_booleans.py
: Boolean values and operations.04_exercise.py
: A small exercise on string encryption.05_lists.py
: Lists, list operations, and methods.06_type_casting.py
: Explicit and implicit type casting in Python.07_input.py
: Taking input from the user and type handling.
Strings are a vital data type in Python, and understanding how to manipulate them is crucial for text data processing, which is commonly used in ML applications like Natural Language Processing (NLP).
08_dictionaries.py
: Introduction to dictionaries, key-value pairs, and dictionary methods.09_tuples.py
: Tuples, immutability, and tuple methods.10_sets.py
: Sets in Python and their unique properties.11_conditionals.py
: Conditional statements likeif
,elif
, andelse
.12_loops.py
: Loops in Python –for
andwhile
loops.13_range.py
: Usingrange()
to generate sequences.14_loop_controls.py
: Break, continue, and pass for controlling loop behavior.
Understanding how to handle user input is essential, especially when building interactive applications and systems, including ML model deployment.
15_function_basics.py
: Basic function structure and how to define and call functions.16_function_parameters.py
: Positional, default, and keyword parameters in functions.17_return_values.py
: Working with return values in functions.18_docstrings.py
: Adding documentation to your functions using docstrings.19_args_kwargs.py
: Understanding*args
and**kwargs
to handle flexible arguments in functions.20_function_scope.py
: Exploring local, global, and non-local scope in functions.
Data structures are the foundation of organizing and storing data, a key aspect of any ML workflow.
21_good_function_qualities.py
: Writing clean and efficient functions.22_map_function.py
: Usingmap()
to apply functions to sequences.23_filter_function.py
: Usingfilter()
to filter data based on a condition.24_zip_function.py
: Combining multiple iterables usingzip()
.25_reduce_function.py
: Reducing a list into a single value usingreduce()
fromfunctools
.
These are higher-order functions that are used frequently in data processing tasks, especially in data science and ML.
26_list_comprehension.py
: Creating lists in a concise and readable manner using list comprehension.27_set_comprehension.py
: Set comprehension for creating sets.28_dict_comprehension.py
: Creating dictionaries using comprehension for cleaner and more efficient code.29_modules_and_packages.py
: Introduction to Python modules and packages, which are essential for organizing larger Python projects, including ML projects.
List, set, and dictionary comprehensions allow you to write more concise and readable code, which is extremely useful when working with data.
Modules and packages help organize Python code into reusable components. In ML projects, modules can be used to manage code for data loading, preprocessing, training, and evaluation.
git clone https://github.com/Hamama-Komal/Python_Lectures.git