sss;dfklj

This commit is contained in:
cramsey
2025-12-03 13:06:34 -05:00
parent 17475bc26b
commit 9a25d726ce
3 changed files with 60 additions and 3 deletions

7
Feedback.txt Normal file
View File

@@ -0,0 +1,7 @@
Current Grade - 75
Feedback:
1. You have functions in the transform.py file that are not working correctly which breaks any code that calls those. See the two comments in the transform.py file
2.

View File

@@ -27,7 +27,7 @@ from transform import (
get_y_values,
)
def draw_scatterplot(data, size=5, color="black"):
def draw_scatterplot(data, size, color):
"Draws a scatter plot, showing the data"
prepare_screen()
draw_axes(data)
@@ -35,9 +35,48 @@ def draw_scatterplot(data, size=5, color="black"):
def draw_axes(data):
"Draws the scatter plot's axes."
draw_x_axis()
x_values = get_x_values(data)
xmin, xmax = bounds(x_values)
ticks = get_tick_values(xmin, xmax)
for tick in ticks:
screen_x_position = scale(tick, xmin, xmax, 0, constants.PLOT_WIDTH)
draw_x_tick(screen_x_position, tick)
draw_y_axis()
y_values = get_y_values(data)
ymin, ymax = bounds(y_values)
ticks = get_tick_values(ymin, ymax)
for tick in ticks:
screen_y_position = scale(tick, ymin, ymax, 0, constants.PLOT_WIDTH)
draw_y_tick(screen_y_position, tick)
def draw_points(data, color, size):
"Draws the scatter plot's points."
xmin, xmax = bounds(get_x_values(data))
ymin, ymax = bounds(get_y_values(data))
"""
1. We only want the max and min the x values in the first line of this code and max and min for the y values in the second line of this code.
Right now, when you pass data, it's passing a list with all of the points wich include BOTH x and y.
What function do we have that we wrote that will give us a list of JUST the x values in the points and JUST the y values in the points?
Use that function to change data to a list of just the x or y values you want.
2. Once we have a single value assigned to each of the variables of xmin, xmax, ymin and ymax we can call the scale function correctly for each point.
3.You need to take each point in your data set that is being passed into this function and scale it to your screen and then we will draw the point on the screen.
To do this, you will want to write a for loop that will iterate through each of the points in your data set. for point in data:
Remember that each point is a piece of data that looks like this - (x,y) - this is a data type called a tuple.
So, we'll want to separate out the x and y from that piece of data.
if we say x = point[0]
how would we find the y = ????
s
"""
for point in data:
x=point[0]
y=point[1]
pos_x = scale(x, xmin, xmax, 0, constants.PLOT_WIDTH)
pos_y = scale(y, ymin, ymax, 0, constants.PLOT_HEIGHT)
draw_point(pos_x, pos_y, color, size)
with no_delay():
data = generate_data(50, 10, 500, 5, 400, 1000)

View File

@@ -18,7 +18,7 @@ def minimum(data):
"Returns the smallest number in data"
lowest = None
for number in data:
if lowest is none:
if lowest is None:
lowest = number
if number < lowest:
lowest = number
@@ -28,6 +28,12 @@ def bounds(data):
"Returns a list of the smallest and largest numbers in data"
highest = maximum(data)
lowest = minimum(data)
###########################
###########################
# You are not returning anything here. write a return statement that returns the highest and lowest number
###########################
###########################
return [lowest, highest]
def clamp(value, low, high):
"""Clamps a value to a range from low to high.
@@ -55,8 +61,13 @@ def ratio(value, start, end):
def scale(value, domain_min, domain_max, range_min, range_max):
"Given a value within a domain, returns the scaled equivalent within range."
scale = range_min + ((ratio(value, domain_min, domain_max))*(range_max, range_min))
return scale
#return scales
###########################
###########################
# if you return scales (with an s) you are essentiallly returning nothing because you have only defined scale
###########################
###########################
def get_x_values(points):
"Returns the first value for each point in points."