-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot points.py
More file actions
29 lines (20 loc) · 764 Bytes
/
plot points.py
File metadata and controls
29 lines (20 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import matplotlib.pyplot as plt
from numpy import*
def generate_quiz_plot(num_points):
x = random.rand(num_points)
y = random.rand(num_points)
plt.scatter(x, y, color='blue')
plt.title("Count the Number of Points in the Plot")
plt.xlabel("X-axis")
plt.ylabel("Y-axis")
plt.show()
return num_points
def ask_question(correct_answer):
user_answer = int(input("How many points are in the plot? "))
if user_answer == correct_answer:
print("Correct! You guessed the right number of points.")
else:
print(f"Wrong! The correct number of points was {correct_answer}.")
num_points = random.randint(5, 21)
correct_answer = generate_quiz_plot(num_points)
ask_question(correct_answer)