Assignment
1️⃣ Lambda Functions, map(), filter(), reduce() (6 Assignments)
Assignment 1: Using a Simple Lambda Function
🔹 Task: Create a lambda function to find the square of a number. 🔹 Example Snippet:
square = lambda x: x ** 2
print(square(5)) # Output: 25Assignment 2: Using Lambda with map()
🔹 Task: Convert a list of integers to their squares using map().
🔹 Example Snippet:
numbers = [1, 2, 3, 4, 5]
squared = list(map(lambda x: x ** 2, numbers))
print(squared) # Output: [1, 4, 9, 16, 25]Assignment 3: Using Lambda with filter()
🔹 Task: Filter even numbers from a list. 🔹 Example Snippet:
numbers = [1, 2, 3, 4, 5, 6]
evens = list(filter(lambda x: x % 2 == 0, numbers))
print(evens) # Output: [2, 4, 6]Assignment 4: Using Lambda with reduce()
🔹 Task: Find the product of all elements in a list using reduce().
🔹 Example Snippet:
Assignment 5: Using map() with Multiple Lists
🔹 Task: Add corresponding elements of two lists using map().
🔹 Example Snippet:
Assignment 6: Using filter() with Strings
🔹 Task: Filter out words with more than 3 letters. 🔹 Example Snippet:
2️⃣ Decorators & Generators (6 Assignments)
Assignment 7: Creating a Simple Decorator
🔹 Task: Write a decorator that prints Before function call and After function call.
🔹 Example Snippet:
Assignment 8: Using a Decorator with Arguments
🔹 Task: Modify a function to print a custom message before execution. 🔹 Example Snippet:
Assignment 9: Using Multiple Decorators
🔹 Task: Apply two decorators to the same function. 🔹 Example Snippet:
Assignment 10: Creating a Simple Generator
🔹 Task: Write a generator that yields numbers from 1 to 5. 🔹 Example Snippet:
Assignment 11: Using Generators for Fibonacci Sequence
🔹 Task: Generate the first 10 Fibonacci numbers. 🔹 Example Snippet:
Assignment 12: Generator for Infinite Number Sequence
🔹 Task: Create a generator that produces numbers infinitely. 🔹 Example Snippet:
3️⃣ Working with sys Module (4 Assignments)
Assignment 13: Getting Python Version
🔹 Task: Print the Python version using sys.
🔹 Example Snippet:
Assignment 14: Command Line Arguments
🔹 Task: Print all command-line arguments passed to the script. 🔹 Example Snippet:
Assignment 15: Exiting a Script with sys.exit()
🔹 Task: Exit the script after printing a message. 🔹 Example Snippet:
Assignment 16: Finding Max Recursion Depth
🔹 Task: Get the maximum recursion depth using sys.
🔹 Example Snippet:
4️⃣ Understanding os and shutil Modules (4 Assignments)
Assignment 17: Getting the Current Working Directory
🔹 Task: Print the current working directory using os.
🔹 Example Snippet:
Assignment 18: Listing Files in a Directory
🔹 Task: Print all files and folders in the current directory. 🔹 Example Snippet:
Assignment 19: Creating & Removing a Directory
🔹 Task: Create and remove a directory using os.
🔹 Example Snippet:
Assignment 20: Copying a File with shutil
🔹 Task: Copy a file using shutil.
🔹 Example Snippet:
Last updated