Additional Mini Scratch Activities
The purpose of the Scratch activities below is for you to help apply what you know in Scratch to raw code in programming languages like Java. Every single activity here has a version written in Java on the "Challenging Java Exercises" page. This way, when you do encounter longer lines of real code, it will feel less intimidating and you will be familiar with the structure and goal of each exercise.
Writing a Short Story
Welcome to A Cat's Story! Click the green flag to be taken through different events in the cat's life, and see how it ends...
Give your own answer into the project and press "enter." If you're still interested, check out the project, remix it, and see if you can continue the story and give it the ending you want!
This code uses the "broadcast" block a lot to send messages through the project, telling other sprites when to appear and disappear or when the backdrop should change. Notice how every time a message is broadcasted, there is a "receiving" block somewhere else in the project that follows up with an action.
Printing with Loops
Welcome to Homework Sentences! Click the green flag to run the program, and then follow the instructions.
Open the project, remix it. Go to the "HI" sprite and change the "repeat" block to "10". Then, click on the backdrop, go to the "backdrop" tab, and change the wording so that it says "print 'HI' ten times." Then see what happens.
This project uses loops, which you should be rather familiar with. Note how you as the programmer do not need to keep writing new "HI"s, since the blocks within the loop create a clone each time for you, waiting a second in between every time.
True-or-False Math Equations
Welcome to Math Homework: Addition! Click the green flag to run the program; it will tell you to put in a few numbers.
To see the code, open the project and See Inside. No need to change anything, but take a look at how the two different responses show and hide at the appropriate times.
The key of this project is to use operators and conditional statements. The two response sprites receive information on whether the math equation is true or false by checking the comparison operator. It will either appear or stay hidden based on previous conditions. Number1, number2, and sum are all variables. When you type in three numbers, the code sets those three numbers to these variables and then tests the operation: number1 + number2 = sum, checking if it's true or false.
Quotients and Remainders
Welcome to Math Homework: Division! Click the green flag to run the program; follow the instructions given by the sprite.
To see the code, open the project and remix it. There is no need to change anything.
This project also uses a lot of operators and conditional statements. After receiving the divisor and dividend from the user, the code sets the variables to these values. It performs the division function and finds the quotient by rounding. It will subtract by 1 if the quotient ends up too high after rounding. The "mod" operator block returns the remainder. The code also has "join" blocks to simply put different parts of a sentence together.
Welcome to Prime Number Class! Click the green flag to run the program and go from there.
To see the code, open the project and remix it. There is no need to change anything. It's rather complicated, so don't worry if you do not understand it. If you do, amazing!
This project uses a great combination of loops, conditional statements, and operators! Can you locate them? Can you figure out what they mean? We can use test numbers (the variable i), the "mod" operator block, and a loop to figure out if a number has factors other than 1 and itself (that means it is not a prime). Remember, 2 is the only even prime number and negative numbers are not considered prime. These are given separate cases.