BYU logo Computer Science

To start this lab, download this zip file.

Lab 3 - Introduction to Bit

Install byubit

In your terminal:

conda activate cs110
pip install byubit

What does it draw?

On a piece of scratch paper, draw out what you think each code snippet will draw.

You can copy the code into a script to run it and see the result.

from byubit import Bit


@Bit.run_from_empty(5, 3)
def do_stuff(bit):
    bit.paint('blue')
    bit.move()
    bit.move()
    bit.paint('green')
    bit.left()
    bit.move()
    bit.move()
    bit.paint('red')
from byubit import Bit


@Bit.run_from_empty(3, 3)
def do_stuff(cosmo):
    cosmo.move()
    cosmo.paint('blue')
    cosmo.left()
    cosmo.move()
    cosmo.paint('blue')
    cosmo.move()
    cosmo.left()
    cosmo.move()
    cosmo.paint('blue')
    cosmo.right()
    cosmo.right()
    cosmo.move()
    cosmo.move()
    cosmo.paint('blue')

Instructions

For the activities in this lab, you will implement several functions.

Your solution is correct when there are no comparison errors.

Turn in all of the files that you complete.

Activity: Red Dot

Finish the code in red_dot.py to produce the following image.

red dot

Activity: All the colors

Run the script all_the_colors.py. It will finish with a comparison error.

Implement the function all_the_colors so there is no comparison error at the end.

First, draw out your strategy.

Second, implement the function.

Activity: Fix me

The file fix_me.py has an error in it.

Run the file and observe the error.

Examine each step to understand where the error is happening.

Correct the error.

Activity: Fix me too!

The file fix_me_too.py has all kinds of errors. Fix them all. :)

Activity: Make me smile

Implement the function in make_me_smile.py to complete the image.

Activity: Picasso

Now it’s your turn!

Write a script called picasso.py

In it put a function called picasso that runs from an empty 8x8 canvas.

Draw whatever you want.

πŸ§‘πŸΌβ€πŸŽ¨

Rules:

  • you have to move/turn/paint at least 20 times

Grading

ActivityPoints
red_dot.py5
all_the_colors.py5
fix_me.py5
fix_me_too.py5
make_me_smile.py5
picasso.py5