James Madison University, Fall 2022 Semester
Lab07: Finch robot dance party and CodingBat
Background
And now, the moment you've all been waiting for...ROBOTS! In today's lab, you will write code to make a Finch robot do a "square" dance. For this lab, you will work in teams of two.
Objectives
Implement an algorithm that uses repetition and conditionals in a high-level language.
Collaborate with others to gain insight, interpret data, and solve problems using computation.
Part 1: Hello, Finch!
Your first task is set up your team computer so you can write Python programs to control the Finch. On Thursday, your team will need to set up at least one laptop to use the Finch. Refer to the canvas announcements about the Finches.
-
To avoid overwriting each other's files, please rename your programs to username.py (replace with your e-ID).
-
Open your programs in Thonny and take turns running and debugging them. The goal is to be as creative as possible!
-
At a minimum, your Finch robot should move forward and backward, turn and swivel, and change colors.
Part 2: Square Dancing
Now that you have created your own dance moves, can you do the same dance as everyone else?
-
Create a new file named square.py. Write your name and your partner's name at the top.
-
With your lab partner, write Python code that performs the following dance pattern:
Move in a square pattern, full speed ahead, for 1 second each side. Move in a square pattern, full speed reverse, for 0.5 seconds each side. Repeat forever...
-
When you are ready, bring your robot to the dance floor! Make modifications as needed.
You need to have at least three loops (an outer loop and two inner loops). Avoid the temptation to copy and paste the same code four times. For bragging rights, see if you can get the Finch to change colors on each side of the square.
Part 3: CodingBat Logic
Download: LabBat.py |
This work does not involve the Finches. You can continue to work with your partner or on your own. If with a parnter, put both names as comments in the file and submit the files for each of you on canvas. CodingBat is a free site of live problems to build skill in Java and/or Python. It was created by Nick Parlante, who is Computer Science lecturer at Stanford. The name "CodingBat" was based on the Greek word "bat" meaning "this domain was available" (or so they say).
-
Open the LabBat.py file, go to the codingbat site as given in the comments, and complete the required problems in your web browser (that is the codingbat site). Then copy/paste your code from codingbat.com into your LabBat.py file (you can use thonny here) where appropriate.
-
Before you submit the lab, make sure you can run the entire LabBat.py file in Thonny. If you get an error, you may have pasted your code incorrectly. Make sure the indenting is consistent.
Submission Instructions
Submit your username.py, square.py, and LabBat.py files via canvas.jmu.edu by 5pm on Friday.