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?
Choose the best answer.
- hi
Python Challenge
NumPy & Matplotlib: Generate Numbers and Plot a Histogram
Complete the two-part coding challenge below:
- Part 1 – NumPy: Use
numpyto generate an array of 3 random numbers (usenp.random.rand(3)or similar) and print them. - Part 2 – Histogram: Plot a histogram of those 3 numbers where each bar is colored red, blue, and green respectively. Use
matplotlibto display the chart.
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
colorparameter in Matplotlib. - Chart Labeling: How to add a title, axis labels, and custom tick labels using
plt.title(),plt.xlabel(),plt.ylabel(), andplt.xticks().
⚠️ Key Points to Pay Attention To
- Bar chart vs. Histogram:
plt.bar()is used for categorical/indexed data, whileplt.hist()is used for frequency distribution. In this exercise, we usedplt.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
colorlist passed toplt.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. Usenp.random.seed()if you need reproducible results. - Calling
plt.show(): Always callplt.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) ornp.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?