Education Technology

Stars, Stripes and Sparkles! Try These 3 Coding Activities for July Fourth Fun

Posted 06/26/2023 by TI Staff

July 4 is upon us. To the rest of the world, it’s just another day. But, in the U.S., it’s Independence Day, when the nation recognizes the adoption of the Declaration of Independence on July 4, 1776. Americans celebrate the day with family, friends, barbeques and parades, and end it with a bang of fireworks! We thought we’d join in on the fun with some patriotic-themed programming.

Here are three patriotic-themed activities you can try using Python programing on the TI‑Nspire™ CX II and the TI‑84 Plus CE Python graphing calculators.

Red Line




Create star explosions in the sky!
This is a fun, experimental activity that lets you create stars in randomly generated colors. The final effect is an explosion of stars on the screen with lots of opportunity to customize your final display along the way.

Let’s take a peek at the math in the code to make a single star polygon.



What do you notice?
  • n is an odd number between 5 and 11. This will be the number of vertices for the polygon.
  • Int () is a python function that converts a number from the parenthesis to an integer.
  • To make a simple polygon we use 360/n for the turning angle since the sum of the exterior angles of a polygon is 360 degrees.
  • Notice this code multiplies the value r with 360/n — why does it do this?


But what about a star polygon? How can we make more or fewer points?
  • r is the number of revolutions made to complete a star polygon.
  • How many points on a star does the value r= int(n/2) create?
  • What would happen if you made this value smaller? Would you get more or fewer points?


Next, change and customize your star display by playing with sizes, shapes and colors. This project is available in the Python modules section of TI Codes for the TI‑Nspire™ CX II and the TI‑84 Plus CE Python graphing calculator.


Go ahead, try this activity! Next steps:

Red Line




Celebrate by flying a flag!
Now that you know how to make some stars, let’s add some stripes! This U.S. flag is a modification of an activity that draws out the Texas flag. Using flags as an artwork template is a great opportunity to explore and experiment with your coding skills. Drawing the Texas flag activity can be found in the same Python modules section of TI Codes — this time under TI Draw > Mini Project 2 (MP2) section.



Let’s start with the Texas flag. What do we notice? There are three colored rectangles and one large star. For this program you can use the ti_draw functions for the rectangles and the Turtle module to make the star in the same program.

But, what would it take to make the U.S. flag? Take another look at the U.S. flag. Notice there are six columns with five stars each and four columns with five stars, for a total of 50 stars.

Now, let’s take a peek at the coding.



This section makes four columns of five stars at the proper positions in the blue field.
  • What do we think the for loop does?
  • What part of the code do we think defines the column?
  • What do we think the function star() does?

This project is available in Python modules for the TI‑Nspire™ CX II graphing calculator.


Go ahead, try this activity! Next steps:
  • Download the Turtle module onto your graphing calculator.
  • Follow the module online under TI Draw, Mini Project 2 – Flags.
  • Download the teacher notes for quick reference.

  • Red Line




    Coding challenge: Make sparkles in the night sky!
    Finally, let’s end with another style of firework display with this coding challenge. This design is modified from a completely different activity and is another great example of what a little bit of experimentation can do after learning basics from the TI Codes modules.

    The original activity created explosions to celebrate the end of a game. It was originally written in TI‑Basic. This activity is part of the Beyond Basics section of TI‑Basic programming under Basketball Game > Mini Project (MP8) The Trophy.

    Take a look at the original activity screen. What do we notice?



    Now take a look at our modified animation again.



    What differences do we notice that could be explored?
    • Colors
    • Parabola shapes
    • A starting “rocket”
    • Plus, this program was written with Python

    Let’s look at the translated code from the TI-Basic version to this adapted for the Python environment.



    A close inspection of the code above reveals that the arcs of the blue and white fireworks display are each a different parabola emanating from the same point (80, 160).

    Try adding a while loop and some random values into the program. What other variations could you create?

    Want to try this coding challenge? Next steps:
    Red Line




    Exploring Python coding with TI Codes
    The TI Codes Python modules offer step-by-step instructions so users of any level can follow along and learn coding basics with TI technology. If you have an older TI-84 graphing calculator model that does not do Python, you can still learn and teach coding with our TI Codes Basic modules — similar projects, just in TI‑Basic!

    You can use these modules to help lead a class together through exploration and discovery, assign modules as extra credit or even use for enrichment/after-school opportunities.

    Adding coding opportunities to your classroom or summer camp gives students opportunities to flex their creative and critical thinking skills. Try an activity, and Happy Independence Day!



    These activities were created by John Hanna. Hanna is a retired teacher splitting time between sailing in New Jersey and mountain biking in Florida (did he get that backwards?), still getting kicks out of working with TI to provide feedback on new products, and developing meaningful programming content for mathematics and science ... and still having fun with all the graphing calculators and the accompanying toys.