Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Challenge: Identify Concurrency Opportunities | Introduction to Concurrency
Quizzes & Challenges
Quizzes
Challenges
/
Python Multithreading and Multiprocessing

bookChallenge: Identify Concurrency Opportunities

Imagine you are developing a Python application that automates data handling for a research team. The application has three main tasks: first, it downloads several large CSV files from different remote servers; second, it processes each downloaded file to clean and transform the data; third, it generates summary statistics and plots from the processed data and saves the results to disk. Each file is independent—downloading one does not depend on another, and processing or analyzing one file does not depend on others.

Aufgabe

Swipe to start coding

Write a function identify_concurrency_opportunities(tasks) that takes a list of task descriptions as strings. For each task, determine if it could be run concurrently with the others, and explain why. Return a dictionary mapping each task description to either "concurrent" or "sequential" along with a brief explanation (as a string) for your choice.

  • For each item in the tasks list, decide if it is independent of the others and could be performed at the same time (concurrent), or if it must wait for another task to complete (sequential).
  • Add a key for each task in the returned dictionary. The value should be a tuple: the first element is either the string "concurrent" or "sequential", and the second element is your explanation.
  • Example output:
    {
        "Download CSV files": ("concurrent", "Each file can be downloaded independently."),
        "Process files": ("concurrent", "Each file can be processed independently after download."),
        "Generate statistics and plots": ("concurrent", "Analysis for each file can be done independently after processing.")
    }
    

Lösung

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 1. Kapitel 3
single

single

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

Suggested prompts:

Can you suggest how to structure the code for these three tasks?

What Python libraries would be best for downloading, processing, and plotting the data?

How can I make the application efficient when handling multiple large files?

close

bookChallenge: Identify Concurrency Opportunities

Swipe um das Menü anzuzeigen

Imagine you are developing a Python application that automates data handling for a research team. The application has three main tasks: first, it downloads several large CSV files from different remote servers; second, it processes each downloaded file to clean and transform the data; third, it generates summary statistics and plots from the processed data and saves the results to disk. Each file is independent—downloading one does not depend on another, and processing or analyzing one file does not depend on others.

Aufgabe

Swipe to start coding

Write a function identify_concurrency_opportunities(tasks) that takes a list of task descriptions as strings. For each task, determine if it could be run concurrently with the others, and explain why. Return a dictionary mapping each task description to either "concurrent" or "sequential" along with a brief explanation (as a string) for your choice.

  • For each item in the tasks list, decide if it is independent of the others and could be performed at the same time (concurrent), or if it must wait for another task to complete (sequential).
  • Add a key for each task in the returned dictionary. The value should be a tuple: the first element is either the string "concurrent" or "sequential", and the second element is your explanation.
  • Example output:
    {
        "Download CSV files": ("concurrent", "Each file can be downloaded independently."),
        "Process files": ("concurrent", "Each file can be processed independently after download."),
        "Generate statistics and plots": ("concurrent", "Analysis for each file can be done independently after processing.")
    }
    

Lösung

Switch to desktopWechseln Sie zum Desktop, um in der realen Welt zu übenFahren Sie dort fort, wo Sie sind, indem Sie eine der folgenden Optionen verwenden
War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 1. Kapitel 3
single

single

some-alt