Start writing your content here...

Let's start with the mathematical definition. Let be a graph with a set of nodes (vertices) , a set of edges , label of node and a neighbors of node , , there are 3 types of homophily ratios:

Let's start with the mathematical definition. Let be a graph with a set of nodes (vertices) , a set of edges , label of node and a neighbors of node , , there are 3 types of homophily ratios:

a coding quiz, first numpy 3 numbers, then plot histgram. in red blue and green color respectively.

Multiple Choice

Question 1 of 1

Look at the slide below. Which concept is Hinton introducing here?

Hinton slide

Choose the best answer.

  1. hi

Python Challenge

NumPy & Matplotlib: Generate Numbers and Plot a Histogram

Complete the two-part coding challenge below:

  1. Part 1 – NumPy: Use numpy to generate an array of 3 random numbers (use np.random.rand(3) or similar) and print them.
  2. Part 2 – Histogram: Plot a histogram of those 3 numbers where each bar is colored red, blue, and green respectively. Use matplotlib to display the chart.
Python idle

Run the code first so AI Tutor can see the latest output or error.

Hints

Reference Solution

Conclusion

Great work completing the NumPy & Matplotlib coding challenge! Here's a summary of what you should take away from this exercise:

🔢 What You Learned

  • NumPy Random Number Generation: How to use np.random.rand(n) to quickly generate an array of n random floating-point numbers between 0 and 1.
  • Bar Chart Visualization: How to use plt.bar() to create a bar chart, passing x-positions, heights (values), and a list of colors.
  • Color Customization: How to assign individual colors (red, blue, green) to each bar using the color parameter in Matplotlib.
  • Chart Labeling: How to add a title, axis labels, and custom tick labels using plt.title(), plt.xlabel(), plt.ylabel(), and plt.xticks().

⚠️ Key Points to Pay Attention To

  • Bar chart vs. Histogram: plt.bar() is used for categorical/indexed data, while plt.hist() is used for frequency distribution. In this exercise, we used plt.bar() to display individual values with distinct colors — be careful not to confuse the two.
  • Array Indexing: NumPy arrays are 0-indexed. When setting x-positions as [0, 1, 2], make sure the number of positions matches the length of your data array.
  • Color List Length: The color list passed to plt.bar() must match the number of bars. A mismatch will cause an error or unexpected coloring.
  • Randomness: Since np.random.rand() generates different values each run, your chart will look slightly different every time. Use np.random.seed() if you need reproducible results.
  • Calling plt.show(): Always call plt.show() at the end to render and display your plot, especially in script-based environments.

Multiple Choice

Question 1 of 2

Listen to the clip. Is it in 3/4 or 4/4 time?

🚀 Next Steps

  • Try generating more numbers (e.g., 10 or 100) and use plt.hist() to see a true frequency histogram.
  • Explore other NumPy functions like np.random.randn() (normal distribution) or np.linspace() for structured data.
  • Experiment with Matplotlib styling: try adding grid lines, changing bar width, or using a different color palette.

Multiple Choice

Question 1 of 1

Angel and his family go to a restaurant and spend 9 on drinks. Angel wants to leave a 20% tip. Which proportion will Angel use to find the amount of the tip?