Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion 46_Generators.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# A generator function is a special type of function that returns an iterator object. Instead of using return to send back a single value, generator functions use yield to produce a series of results over time.
"""A generator function is a special type of function that returns an iterator object.
Instead of using return to send back a single value, generator functions use yield to produce a series of results over time."""

def fun(max):
cnt = 1
Expand Down
4 changes: 2 additions & 2 deletions 47_Yield.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# yield Keyword -> In Python, yield keyword is used to create generators, which are special types of iterators that allow values to be produced lazily, one at a time, instead of returning them all at once.
"""Yield keyword is used to create generators, which are special types of iterators that allow values to be produced lazily, one at a time, instead of returning them all at once."""

# Syntax
# def generator_function():
# yield value


# Examples of yield
"""Examples of yield"""
# Example 1: Simple Generator to Yield Numbers Sequentially
def fun(m):
for i in range(m):
Expand Down
13 changes: 7 additions & 6 deletions 48_Import_Module.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# Import module in Python
# In Python, modules help organize code into reusable files. They allow you to import and use functions, classes and variables from other scripts.
"""Import module in Python
In Python, modules help organize code into reusable files.
They allow you to import and use functions, classes and variables from other scripts."""

# Importing built-in Module
import math
pie = math.pi
print("Value of pi:", pie)


"""Importing External Modules
To use external modules, we need to install them first, we can easily install any external module using pip command in the terminal."""

# Importing External Modules
# To use external modules, we need to install them first, we can easily install any external module using pip command in the terminal, for example:

# pip install "module_name"
# Example
"""pip install pandas"""

import pandas

Expand Down
7 changes: 4 additions & 3 deletions 49_Virtul_env.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# A virtual environment is an isolated Python environment that allows you to manage dependencies for each project separately. It prevents conflicts between projects and avoids affecting the system-wide Python installation.
""" A virtual environment is an isolated Python environment that allows you to manage dependencies for each project separately.
It prevents conflicts between projects and avoids affecting the system-wide Python installation."""

# How to Create a Virtual Environment in Python
# We use the virtualenv module to create isolated environments. It creates a folder with all necessary executables for the project.
"""How to Create a Virtual Environment in Python
We use the virtualenv module to create isolated environments. It creates a folder with all necessary executables for the project."""

# Step 1: Installing virtualenv
"""$ pip install virtualenv"""
Expand Down