Skip to content

Week 6: Programming

Assignments

  • Design and implement a simple game or quiz using a block programming language. It is recommended that the quiz/game can be used in the classroom.
  • Include in your learning diary the code and several screenshots of your application. You can even include a video. Include also the programming platform.
  • Remember to include the code and pictures of the generated application in your learning diary.
  • When you design a DF learning activity, how do you take into account diversity? Could you describe one learning situation in which you did not take into account diversity in planning? How did you solve the situation?
  • What aspects would you need to take into consideration if you have kids with a) learning disabilities, b) physical disabilities, c) emotional disabilities when preparing your DF activities?
  • Do you think your school is ready to a change in mindset? Why? How can you get support from other stakeholders?
  • What are the challenges and opportunities of integrating programming in your classes?

Process

In our Physics class’s Projectile Motion unit, we do an activity called the “Circus Challenge,” in which students attempt to use a cannon to launch a projectile through a pair of hoops. Being a physical activity, this is quite a lot of fun, but there is also a reasonable amount of operational uncertainty in using the cannon, and it is very time-consuming as students can only set up and fire the cannon one at a time. For these reasons, I have decided to make a digital simulacrum of this activity in Python, using a website called EduBlocks, which allows students and educators to learn/teach the language through block coding.

Here is a link to the code.

An explanation for the code can be found in the comments below.

#Start code here
import math   #Import the math library, to allow for trigonometric functions to be used
import random   #Import the random library, to allow the simulation to be different every time
import pygal   #Import the pygal library, to allow the program to visualise the trajectory of the projectile
Initial_Velocity = 10   #Set the initial velocity of the cannon's launch; this can be changed in the program, but is at a set value.
Initial_Height = 2   #Set the initial height of the cannon's launch. Alternatively, the initial velocity and height of the cannon could be up to the user's input, but should remain in this position in the code and also be within a restricted range of values.
print("You are firing a cannon from a height of", Initial_Height, "metres. It has a launch velocity of", Initial_Velocity, "metres per second.")   #Tell the user the set conditions of the cannon
Hoop_Height = round(random.randrange(50, 350)) / 100   #Set a random value for the hoop's height. These values are based around an ideal mean at the same height as the cannon, firing at 20 degrees.
Hoop_Distance = round(random.randrange(400, 900)) / 100
Hoop_Radius = round(random.randrange(25, 100)) / 100   #It is important to give the hoop a radius, so that it is not a single point in space. This allows some margin of error in the shot.
print(Hoop_Distance, "metres away, there is a hoop with a radius of", Hoop_Radius, "metres suspended", Hoop_Height, "metres in the air.")   #Give the user the information about the hoop.
print("Shoot the hoop! Find the right angle to launch the cannon at.")   #Inform the user of their goal
Gravity = -9.81   #Set the value of the acceleration due to gravity at sea level, 9.81 m/s^2
Hit_ = False   #Set up a loop. This loop will close when they have successfully hit the target with their shot.
while not Hit_:
  x = 0   #Starting position (0 metres from the cannon)
  Angle = math.radians(float(input("Launch Angle (degrees): ")))   #Prompt the user to input an initial angle for the launch; this must be in radians, but users will input in degrees
  Time = 0   #Starting time (no time has yet elapsed)
  y = Initial_Height
  ux = Initial_Velocity * math.cos(Angle)   #Use trigonometry to determine the x- and y-components of the initial velocity
  uy = Initial_Velocity * math.sin(Angle)
  print("Horizontal Initial Velocity: ", round(ux * 100) / 100)   #Tell the user how their angle has affected the velocity in each direction
  print("Vertical Initial Velocity: ", round(uy * 100) / 100)
  P_Chart = pygal.Line()   #Initialise a chart for the position of the projectile
  x_List = [x]   #Initialise a list of x values to be used in the chart
  y_List = [y]   #Initialise a list of y values to be used in the chart
  #Set up another loop. This loop will parse through points in time, breaking when either the projectile reaches the hoop or hits the ground, whichever comes first.
  while True:
    Time += 0.05   #Move to the next point in time
    x = ux * Time   #Find the current x-position based on u_x
    y = Initial_Height + uy * Time + (Gravity * Time * Time) / 2   #Find the current height based on the initial height, u_y, and the acceleration of gravity
    if y < 0 or x >= Hoop_Distance:
      print("At time t =", round(Time * 100) / 100, "s")   #This is the breakpoint; tell the user where we are and end the loop.
      print("x =", round(x * 100) / 100, "m")
      print("y =", round(y * 100) / 100, "m")
      break
    elif Time % 0.5 == 0:
      print("At time t =", round(Time * 100) / 100, "s")   #At certain time intervals, tell the user where we are in the trajectory
      print("x =", round(x * 100) / 100, "m")
      print("y =", round(y * 100) / 100, "m")
    x_List.append(round(x * 100) / 100)   #Add the current x- and y-positions to the list of values for the chart
    y_List.append(round(y * 100) / 100)
  Hit_Time = Hoop_Distance / ux   #Calculate the time it took the projectile to get to the hoop's position
  Hit_Height = Initial_Height + uy * Hit_Time + (Gravity * Hit_Time * Hit_Time) / 2   #Calculate the height of the projectile at that point
  if Hit_Height < Hoop_Height + Hoop_Radius and Hit_Height > Hoop_Height - Hoop_Radius:
    print("Congratulations! You've gone through the hoop at a height of", round(Hit_Height * 100) / 100, "metres")   #If the height is within the hoop's radius, you win! End the loop.
    Hit_ = True
  elif Hit_Height > Hoop_Height + Hoop_Radius:
    print("Oh darn! That's a miss! Your shot was", round((Hit_Height - (Hoop_Height + Hoop_Radius)) * 100) / 100, "metres too high.")   #If the shot is too high, tell the user how much they missed by and continue the loop.
  elif Hit_Height <= 0:
    print("Ah, shoot! Your shot impacted the ground", round(Hoop_Distance - x * 100) / 100, "metres in front of the hoop.")   #If the shot hits the ground, tell the user how much they missed by and continue the loop.
  else:
    print("Drat! That's a miss! Your shot was", round(((Hoop_Height - Hoop_Radius) - Hit_Height) * 100) / 100, "metres too low.")   #If the shot is too low, tell the user how much they missed by and continue the loop.
  P_Chart.add("Position (m)", y_List)   #Add the y-values to the chart.
  P_Chart.x_labels = x_List   #Add the x-values to the chart
  P_Chart.render()   #Render the chart with the x- and y-values
  #This is the bottom of the loop; if they missed their shot, return to the top to get a new angle!

If students are doing their calculations properly, they should get it on the first try!

Here is the block code:

Reflection

  • I try to account for diversity in my direct instruction and in my one-on-one/small group time with students by using a variety of methods to deliver information, but I don’t have a particular skill for diversification; I just try to meet each student where they’re at, and sometimes that requires taking some time outside of class to help them individually in a way that works better for them than for the class in general. I do not have any particular stories, either.
  • Learning Disabilities: Make sure that all student material is available in an OCR format to allow for screen-readers to be used (dyslexia); be on-hand or have other students nearby who can help make sense of problems that arise; allow alternative methods of submitting written work (dysgraphia). Chunking and discrete tasks are very useful!
  • Physical Disabilities: Highly individualised to the particular disability. Have all tools easily accessible and within reach; allow them to handle what they can do themselves and others to help them to do what they cannot (with the student’s consent, of course)
  • Emotional Disabilities: Again, highly individualised, but it is always good to have a space to allow students to vent emotions without harming themselves or others or disrupting their classmates. Give them time and patience to work through frustrations.
  • I think that LCC is generally a fairly progressive school when it comes to student diversity of ability, though it is also a school that does not often have students with profound disabilities that seriously affect their education. We have a strong mindset for diversification of lesson and assessment planning, with a L.E.A.D. team that is dedicated to our students, but because of our limited student pool from being a private school, students’ problems are more often stemming from ADHD, learning disabilities, or higher-functioning autism, as opposed to disabilities that would be much more challenging to work around.
  • The primary challenge of integrating programming into a class is that if students are not learning programming as its own subject in another class, it is another thing to have to teach them that is not part of your class’s curriculum. While it is not particularly difficult to get started in coding, the fact that it is new and not directly related to the topic means that students can often need more incentive/buy-in to get the interest to actually begin to learn. The opportunities, however, are abundant, not just in the learning of a new tool or the ability to use creative thinking and problem-solving, but also in that it forces students to think through the specific logic of the problem that they are tackling. This makes it a very useful tool in a subject like Physics, where understanding the logic of a problem is extremely useful for pattern recognition and solving similar problems later.

Tools