You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The intro to py5 and python tutorials have coding challenges at the end of each of them, but there is no answer key #113
The intro to py5 and python tutorials have coding challenges at the end of each of them, but there is no answer key. Should there be one? Should it be on github?
Yes and yes! I use py5 to teach creative coding and this would help a lot. It would show at least one way to solve the challenges and provide teachers with a good standard for learning, teaching, and grading.
Great, I just added some Labels in hopes that someone is interested in working on this. I don't have time at the moment, but this seems like a good task that someone else could pick up and contribute to. @villares , do you know anyone who would be interested in working on this?
See if this helps... I took the one I thought was closest and tried to "refactor". I think it can still be improved, but looks plausible...
#Ch 10 Engine Task theta=0radius=30# this was called speed but I think it is the radius!defsetup():
size(600, 600)
no_fill()
stroke('#FFFFFF')
stroke_weight(3)
defdraw():
globaltheta, radiustheta-=0.08background('#004477')
#translate(width/2, height/2) # let's try without this#circle and pison: side viewpush_matrix() # backup the coordinate transformstranslate(400, 200) # this will be undone by pop_matrix()x=cos(theta)
y=sin(theta)
yc=120# center of the circleline(radius, yc, x*-radius+radius, y*radius+yc)
diameter=radius*2circle(radius, yc, diameter)
#piston arm attached to inner arm: side viewline( x+radius, y*radius+radius,
-x*radius+radius, y*radius+yc)
#piston body: side view rect(x, y*radius, radius*2, radius*2)
#piston body lines: side viewline(x, y*radius+15, x+radius*2, y*radius+15)
line(x, y*radius+10, x+radius*2, y*radius+10)
line(x, y*radius+5, x+radius*2, y*radius+5)
pop_matrix() # resets coordinate transforms# working on the original coordinates: 0, 0, on top left corner piston_body(50, 200, theta)
piston_body(120, 200, theta+PI/3)
piston_body(190, 200, theta+2*PI/3)
defpiston_body(xp, yp, theta):
#piston bodyx=cos(theta)
y=sin(theta)
push_matrix()
translate(xp, yp)
rect(-radius, y*radius*+1, radius*2, radius*2)
line(-radius, y*radius+5, radius, y*radius+5)
line(-radius, y*radius+10, radius, y*radius+10)
line(-radius, y*radius+15, radius, y*radius+15)
line(0, y*radius+30, 0, y*radius+150)
pop_matrix()
Activity
david-dunkley commentedon Apr 25, 2024
Yes and yes! I use py5 to teach creative coding and this would help a lot. It would show at least one way to solve the challenges and provide teachers with a good standard for learning, teaching, and grading.
hx2A commentedon Apr 25, 2024
Great, I just added some Labels in hopes that someone is interested in working on this. I don't have time at the moment, but this seems like a good task that someone else could pick up and contribute to. @villares , do you know anyone who would be interested in working on this?
villares commentedon Apr 25, 2024
Great! I'll ask around!
david-dunkley commentedon Apr 26, 2025
Hi @villares & @hx2A This sounds great! Looking forward to helping y'all out and learning as well! Have a great weekend.
villares commentedon Jun 4, 2025
@david-dunkley, I saw your email today, email is good.
For the record, it's about "chapter 10": https://py5coding.org/tutorials/intro_to_py5_and_python_11_trigonometry_for_animation.html#engine-task
I'll try to have a look this week!
david-dunkley commentedon Jun 4, 2025
Hi @villares ,
Yes, 'Ch 10' Engine Task.
Thanks for the message and I look forward to hearing from you!
Best,
David
villares commentedon Jun 9, 2025
Hi @david-dunkley!
See if this helps... I took the one I thought was closest and tried to "refactor". I think it can still be improved, but looks plausible...