Introduction to Programming

Activity: Calculating the Grades

Lesson 7: Logical Operators

In this activity, we will build a grade calculator in PictoBlox. The program will ask the user for their score, then use logical operators and conditional statements to determine and display their grade.

Grading Criteria

Score RangeGrade
90 and aboveA
80 to 89B
70 to 79C
60 to 69D
Below 60F

Setting Up

  • Open PictoBlox and create a New File.
  • Select Block Coding as the coding environment.
  • Choose any sprite — we will use Tobi for this activity.
  • Create a variable called Score.

Building the Script

We will use nested If () Then Else blocks combined with AND operators to check the score range. You will find the blocks in the mentioned palettes:

  • When flag clicked — Events
  • Ask (Enter your score:) and wait — Sensing
  • Set (Score) to (answer) — Variables
  • If (Score ≥ 90) Then: Say (Grade: A) for 3 seconds — Control, Operators, Looks
  • Else If (Score ≥ 80 AND Score < 90) Then: Say (Grade: B) for 3 seconds
  • Else If (Score ≥ 70 AND Score < 80) Then: Say (Grade: C) for 3 seconds
  • Else If (Score ≥ 60 AND Score < 70) Then: Say (Grade: D) for 3 seconds
  • Else: Say (Grade: F) for 3 seconds
Block coding script in PictoBlox with nested if-then-else blocks checking score ranges using AND operators to determine the letter grade

Running the Script

  • Click the green flag to start the program.
  • Enter a score when prompted and press Enter.
  • Watch Tobi display the corresponding grade!
PictoBlox stage showing Tobi with a speech bubble displaying Grade: B after the user entered a score of 85
Save your file with the name Grade Calculator before moving on to the assignment!

Subscribe to our newsletter.

Get updates to news and events.