-
Basic Multithreading:
- Write a Python program that utilizes multithreading to perform two different tasks concurrently.
- Use the
threadingmodule to create two threads, each performing a specific task. - Demonstrate the execution of both threads.
-
Thread Synchronization:
- Extend the previous program to showcase thread synchronization.
- Implement a shared resource (e.g., a counter) and use locks to prevent race conditions.
- Ensure that the shared resource is updated safely by multiple threads.
-
Database Connection:
- Install the
mysql-connector-pythonpackage. - Write a Python script to connect to a MySQL database using the
mysql.connectormodule. - Print a confirmation message upon successful connection.
- Install the
-
Data Retrieval:
- Create a table in the MySQL database with sample data (e.g., a simple user table).
- Write a Python script to query and retrieve data from the table.
- Print the results.
-
Data Insertion and Update:
- Extend the script to insert new records into the table and update existing records.
- Print the updated results after the operations.
- Encourage students to use meaningful variable names and provide comments explaining their code.
- Remind students to handle multithreading synchronization carefully to avoid race conditions.
- Emphasize the importance of securely managing database connections and handling exceptions.
- Encourage experimentation with different scenarios to ensure the correctness of the code.
- Provide feedback on the usage of multithreading and MySQL in their solutions.