Hey everyone!
This week in programming I worked on most of the Branching chapter in pythonroom, and also did a fun turtle race activity in trinket!
1. In branching, I learned about:
-if statements
-conditions
-else statements
-multiple if statements
-elif statements
-nested if statements
Below is a visual chart on how the if, elif, and else statements work together to print appropriate statements, given someone's age. Then there is an example of the actual code:
I got the main ideas for the code from a pdf shared from my teacher, which showed me how to create:
This week in programming I worked on most of the Branching chapter in pythonroom, and also did a fun turtle race activity in trinket!
1. In branching, I learned about:
-if statements
-conditions
-else statements
-multiple if statements
-elif statements
-nested if statements
Below is a visual chart on how the if, elif, and else statements work together to print appropriate statements, given someone's age. Then there is an example of the actual code:
Below is my coding for a game of rock, paper, scissors:
I really enjoyed this part section, even though it was quite frustrating. The concepts of if, then, and else came relatively easy to me. I understood that there was a certain notation for everything, and that you could provide many possibilities for something, simply given if it was bigger, equal, or smaller to something else. The thing I did not enjoy (especially in the rock, paper, scissors example) was having to go through every single condition, to make sure that every possibility was covered. This felt repetitive and extra, but I understand that it has to be done.
Also at the end of each example, it gave opportunities to make the game against the computer, which used random integers, given by the computer, which would then correlate to certain conditions. I liked that.
2. The other thing that I worked on was creating a turtle race! Here is the link to mine: https://trinket.io/python/b0c4aad678. Also, here is a picture of my turtle race:
|
![]() |
-the numbers with straight lines
-a turtle
-the randint function that makes each turtle move a random amount each time in a loop
-a loop
After playing around with it for a while, I got around to creating:
-7 turtles (I could create many more)
-dashed lines for the race track, instead of solid lines
-the name of my race on the top
And, I was most proud of myself because I figured out how to prompt the user to name each turtle and give it its color, and then put the name next to the turtle and have their turtle be their desired color. I did this by creating variables for each turtle about their name and their color. Below is the code for one turtle:
#make turtle 1
turtle1 = Turtle()
turtle1.shape('turtle')
turtle1.penup()
turtle1.goto(-140, 120)
turtle1.pendown()
speed(0)
color1 = input("Color of Turtle 1: ")
turtle1.color(color1)
for turn in range(10):
turtle1.right(36)
goto(-180, 117)
write(input("Name of Turtle 1: "))
All in all, I thought that this was pretty fun, and I liked that I was able to change it up a little to what I wanted. I learned more about the loop functions and the turtle functions.
The one thing that I wished I could do was create a button, that when pressed, would start the turtle race. I also wanted a way for it to print whichever turtle crossed the finish line first. I couldn't figure it out because the turtles were only moving random amounts, not coded in any way against each other.
Hopefully in the future I can figure it out!
I've also spent a lot of time helping my classmates figure all of this out. I actually really like helping them because it helps re-solidify the concepts, but also I like seeing it work out for other people.
Thanks for reading and see you next week!
-Mimi
Comments
Post a Comment