Assignment
1️⃣ sys, os, shutil, and subprocess (6 Assignments)
sys, os, shutil, and subprocess (6 Assignments)Assignment 1: Get Python Version Using sys
sys🔹 Task: Print the current Python version using the sys module.
🔹 Example Snippet:
import sys
print("Python version:", sys.version)Assignment 2: Get and Change the Current Working Directory Using os
os🔹 Task: Retrieve the current working directory and change it to /tmp.
🔹 Example Snippet:
import os
print("Current Directory:", os.getcwd())
os.chdir("/tmp")
print("Changed Directory:", os.getcwd())Assignment 3: List Files and Directories Using os
os🔹 Task: Print all files and folders in the current directory. 🔹 Example Snippet:
import os
print("Files and Directories:", os.listdir("."))Assignment 4: Copy, Move, and Delete a File Using shutil
shutil🔹 Task: Create a file, copy it, move it, and then delete it. 🔹 Example Snippet:
Assignment 5: Run a Shell Command Using subprocess
subprocess🔹 Task: Run the ls or dir command using subprocess.
🔹 Example Snippet:
Assignment 6: Open a File Using subprocess
subprocess🔹 Task: Open notepad (Windows) or gedit (Linux/Mac).
🔹 Example Snippet:
2️⃣ Multithreading and Multiprocessing (6 Assignments)
Assignment 7: Create and Run a Thread
🔹 Task: Run a function in a separate thread. 🔹 Example Snippet:
Assignment 8: Create Multiple Threads
🔹 Task: Run multiple threads printing numbers from 1 to 5. 🔹 Example Snippet:
Assignment 9: Use ThreadPoolExecutor for Parallel Execution
ThreadPoolExecutor for Parallel Execution🔹 Task: Execute multiple tasks using ThreadPoolExecutor.
🔹 Example Snippet:
Assignment 10: Create a Multiprocessing Example
🔹 Task: Run a function in a separate process. 🔹 Example Snippet:
Assignment 11: Use ProcessPoolExecutor for Multiprocessing
ProcessPoolExecutor for Multiprocessing🔹 Task: Run multiple processes using ProcessPoolExecutor.
🔹 Example Snippet:
Assignment 12: Use a Queue in Multiprocessing
🔹 Task: Share data between processes using a queue. 🔹 Example Snippet:
3️⃣ Logging & Debugging with logging (4 Assignments)
logging (4 Assignments)Assignment 13: Basic Logging in Python
🔹 Task: Log a simple message. 🔹 Example Snippet:
Assignment 14: Logging Messages to a File
🔹 Task: Log messages to a file instead of the console. 🔹 Example Snippet:
Assignment 15: Use Different Logging Levels
🔹 Task: Demonstrate DEBUG, INFO, WARNING, ERROR, and CRITICAL levels.
🔹 Example Snippet:
Assignment 16: Custom Logging Format
🔹 Task: Change the log message format. 🔹 Example Snippet:
4️⃣ Pylint for Static Code Analysis (4 Assignments)
Assignment 17: Install Pylint
🔹 Task: Install pylint for code analysis.
🔹 Example Command (Terminal):
Assignment 18: Check a Python File with Pylint
🔹 Task: Run pylint on a sample Python file.
🔹 Example Command (Terminal):
Assignment 19: Ignore Specific Warnings in Pylint
🔹 Task: Disable a specific warning in pylint.
🔹 Example Command (Terminal):
Assignment 20: Use a Pylint Configuration File
🔹 Task: Create a .pylintrc file to customize linting rules.
🔹 Example Command (Terminal):
Last updated