Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Challenge: Compare Data Distributions with Seaborn | Data Visualization and Mathematical Functions
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Python for Mathematics

bookChallenge: Compare Data Distributions with Seaborn

When you want to compare the performance of different groups—such as classes taking the same test or participants in an experiment—simply looking at averages does not always reveal the whole story. Comparing data distributions allows you to see differences in spread, outliers, and overall patterns. In educational settings, visualizing the test scores from two classes side by side can help identify which class has more consistent results, whether one group has higher outliers, or if both groups share a similar range of scores. Boxplots are a powerful way to summarize and compare these distributions, as they highlight the median, quartiles, and any potential outliers in a compact visual format.

123456789101112131415161718
import random import seaborn as sns import matplotlib.pyplot as plt # Generate random test scores for two classes class_a_scores = [random.randint(60, 100) for _ in range(30)] class_b_scores = [random.randint(55, 98) for _ in range(30)] # Prepare data for seaborn data = [class_a_scores, class_b_scores] labels = ["Class A", "Class B"] # Create side-by-side boxplots sns.boxplot(data=data) plt.xticks([0, 1], labels) plt.ylabel("Test Scores") plt.title("Comparison of Test Score Distributions: Class A vs Class B") plt.show()
copy
Aufgabe

Swipe to start coding

Write a function that generates two lists of random integers to represent test scores for two different classes. Use seaborn to create side-by-side boxplots comparing the score distributions. Add descriptive labels for the x-axis, y-axis, and a title for the plot.

  • Generate a list of 30 random integers between 60 and 100 for the first class.
  • Generate a list of 30 random integers between 55 and 98 for the second class.
  • Create a side-by-side boxplot comparing the two lists.
  • Label the x-axis with the class names, set a label for the y-axis, and add a plot title.

Lösung

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 2. Kapitel 7
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

close

bookChallenge: Compare Data Distributions with Seaborn

Swipe um das Menü anzuzeigen

When you want to compare the performance of different groups—such as classes taking the same test or participants in an experiment—simply looking at averages does not always reveal the whole story. Comparing data distributions allows you to see differences in spread, outliers, and overall patterns. In educational settings, visualizing the test scores from two classes side by side can help identify which class has more consistent results, whether one group has higher outliers, or if both groups share a similar range of scores. Boxplots are a powerful way to summarize and compare these distributions, as they highlight the median, quartiles, and any potential outliers in a compact visual format.

123456789101112131415161718
import random import seaborn as sns import matplotlib.pyplot as plt # Generate random test scores for two classes class_a_scores = [random.randint(60, 100) for _ in range(30)] class_b_scores = [random.randint(55, 98) for _ in range(30)] # Prepare data for seaborn data = [class_a_scores, class_b_scores] labels = ["Class A", "Class B"] # Create side-by-side boxplots sns.boxplot(data=data) plt.xticks([0, 1], labels) plt.ylabel("Test Scores") plt.title("Comparison of Test Score Distributions: Class A vs Class B") plt.show()
copy
Aufgabe

Swipe to start coding

Write a function that generates two lists of random integers to represent test scores for two different classes. Use seaborn to create side-by-side boxplots comparing the score distributions. Add descriptive labels for the x-axis, y-axis, and a title for the plot.

  • Generate a list of 30 random integers between 60 and 100 for the first class.
  • Generate a list of 30 random integers between 55 and 98 for the second class.
  • Create a side-by-side boxplot comparing the two lists.
  • Label the x-axis with the class names, set a label for the y-axis, and add a plot title.

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 2. Kapitel 7
single

single

some-alt