Week 3 of Code in Place

I’m a little behind on my blogging, eek. I had my grandmother’s burial on Monday, so I had to travel to Calexico and back. It was intense, but I am happy that I was able to go.

So week 3 was last week and it was especially fun because we moved from using Karel to using the console/terminal! This is a big jump for many students, going from “playing” to “super serious coding.” I remember when I moved to the terminal feeling overwhelmed and excited.

This week’s section project was to ask users for a weight and we would calculate what that weight would be on Mars and then print a message with the number. I think this was a great problem to work through as the one of the first without graphics (Karel or Canvas). It wasn’t “tricky” or a huge problem to solve. It was focused on using the concepts and with no visual aide. 

Our check in question this week was “We are moving from Karel to the console, what do you think/feel?” I choose this so we can acknowledge the move and normalize any negative emotions that might come up. I shared with them that there were several times when I was learning to code that I felt that I would never get it, but that it's a skill like any other. With time, practice and giving yourself grace, you can learn. 

If you want to check it out at: bit.ly/cip-week3. It goes over our check in, a light review of the week’s key concepts and then we jump into coding!

This week’s key concepts were:

  • Data Types & built in functions

  • Assigning variables & using variables

  • Comparison operator

Data Types & built in functions

Since the section project was about asking the user for information and printing out on the terminal, I reminded students about input() and print() functions. We went over how input only takes in strings and processes the user's response always as a string. And how print takes in strings. 

Assigning variables & using variables

I couldn’t assume that we would be using unique variable names in the code, we went over the idea of assigning and using variables. The concept I used was drinking coffee and how the coffee_consumed_mg variable gets updated on each line, so the first print would be 100 and the second print would be 200. I also lightly introduced the idea of Constant variables with the AVERAGE_COFFEE_MG variable. 

Comparison operator

As a next step on the section project students could ask users also for which planet they want the weight to be calculated. So I introduced the idea of the Comparison operator. We went over how the string “jessica” and the string “Jessica” wouldn’t be equal because one is has a capital J.

Coding

This time instead of giving students time to “think” about the problem, I went over the instructions and we outlined the “plan” (pseudo coding). Since this was a more “straight forward” project, it wasn’t about figuring out a method to solve, but just following the instructions and focus on the implementation.  

# ask user for the weight -> input()

# type casting the user input into a float 
# need conversation rate variable .378
# multiply weight user gave us & conversation -> new weight 

# RECOMMEND TO LEAVE OUT FOR NOW rounded to two decimal places when necessary.

# print the phrase & new mars weight

I didn’t introduce the section requirement of rounding to two decimals, but a student noticed it. We added it to the steps, but first solved the problem and then we would go back and take care of this.

We were able to solve it with 10 mins to spare, testing as we were going and using type-casting to convert strings to floats and floats to strings. 

We resolved the rounding complexity by using round(), which as far as I knew has not been introduced yet. So I demonstrated how to look up built-in functions and recommended using W3School whenever possible. I went through and demonstrated the “Try it Yourself” functionality, to play with the function. And then went through the Defination, Usage, Syntax and Parameter values in the docs. 

Below is the code that the group came up with: 

"""
Prompts the user for a weight on Earth
and prints the equivalent weight on Mars.
"""

MARS_MULTIPLE = 0.378

def main():
    # ask user for the weight -> input()

    # type casting the user input into a float 
    # need conversation rate variable .378
    # mult weight user gave us & conversation -> new weight 
    
    # RECOMMEND TO LEAVE OUT FOR NOW rounded to two decimal places when necessary.
    
    # print the phrase & new mars weight
    
    earth_weight = input("Enter a weight on Earth: ")
    
    earth_weight = float(earth_weight)
    
    the_equivalent_weight_on_mars = MARS_MULTIPLE * earth_weight
    
    the_equivalent_weight_on_mars = round(the_equivalent_weight_on_mars, 2)
    
    print("The equivalent weight on Mars: " + str(the_equivalent_weight_on_mars))

if __name__ == "__main__":
    main()

Check out a visualizer of what the code below does: https://codeinplace.stanford.edu/cip3/share/e4omFVKWHxSgKAO2StTs

Thoughts

As of today, I have 15 students, which is 3 more than last week. I’m assuming that people who hadn’t participated were “dropped” but once they signed in they were re-added to my section 🤷🏽‍♀️

Something that I found really fantastic was during check in, several students shared that they were excited to be moving away from Karel and more than two used the word “freedom.” It was so optimistic. 

Previous
Previous

Week 4 of Code in Place

Next
Next

Week 2 of Code in Place