Get Your Promposal Ready — Try Balloons and Buttons
It’s prom season, and it can be hard to keep your students from daydreaming about prom night. How about an activity that will grab their attention while you sneak in some programming skills? Plus, be sure to encourage your students to participate in our TI Promposal Contest. It will provide extra motivation for your students to push their creativity. Encourage your students to enter for a chance to win some cash for their prom night!*
To be honest, it’s been quite some time since I have thought about prom (1966; I did not attend any proms but our wedding song in 1970 was “Can’t Take My Eyes Off You” by Frankie Valli). From what I have seen since, kids these days are doing it up big time, with creative tactics to really get a “yes” from their intended target. Puppies, doughnuts, balloons, sky writing, and more … but yes, even calculators are being used to make a fun — and unique — promposal to get a “yes”, and maybe even a giggle too. I mean, who can say no to a pretty little calculator screen?
Let’s take a look at two examples that I wrote for the TI-Nspire™ CX II graphing calculator using Python. I’ll even provide the .tns files if you want to download them to study the code and take a crack at editing to make it uniquely yours. There are also two PDF files explaining the programs in more detail which can help you take the code and do something a little different with it.
Example 1: Just Popped By To Ask You to Prom!
In my promposal research, I came across a picture of a poster covered by balloons to be popped to reveal an invitation written on the poster. That inspired the balloon theme in this project, so I began with the skeleton shown below, balloons.py, which uses my favorite control structure: while get_key() != ”esc”:. The loop body generates a random color (red, green, blue) and draws a filled circle at a random position with a random radius (x, y, r) somewhere on the screen. These circles continue to appear on the screen until the user presses [esc]. Simple, eh? But, then what? More on that shortly.
Example 2: Yes! Or No?
As you can see, this is a fun take on the old circle “YES” or “NO.” But in this Yes/No program, two “buttons” are displayed for the user to select using the cursor. But, surprise, the “No” button is not really clickable! It moves away as soon as the mouse cursor goes over the button. Only the “Yes” button can be clicked. So the requester will always get the answer they had hoped for. A win-win!
What now? How can I (or my students) make my own?
Well, these examples are meant to inspire and motivate you and your students to get creative with those little computers.
These two projects involving balloons and buttons have a lot of common features:
- Both use a graphical display
- Both utilize Python classes (objects)
- Both use get_key() and get_mouse() to determine key presses and mouse cursor positions
- Both make use of a while loop to control the termination of the program
Let’s take a look at four of them in some detail:
1. Graphical display
Are you or your students new to Python? For a quick introduction to graphical programming in Python be sure to study the TI Codes materials, especially Unit 5, which briefly introduces some of the unique TI modules: ti_plotlib and ti_draw. Using the drawing functions found in the ti_draw module makes it a breeze to quickly produce custom graphics screens. There is also new material under the Python modules section that deals specifically with the custom ti_* modules. |
2. Python classes
A class is structure that “encapsulates” the properties and functions (behaviors) of an “object” just like in many other object-oriented programming (OOP) languages like C++ and Java. First, some sample code: class balloon: def draw(self): This code defines a class. Then, to make a balloon object I write: ball = balloon(randint(0, 255), randint(0, 255),randint(0, 255),\ The six arguments are all random integers (three for the color, two for the position on the screen and one for the radius of the balloon). The button class in the Yes/No project is defined in a similar manner. The __init__ function in any class is the constructor. It is called whenever you create a new object variable. Its job is to assign the values of the arguments to the member variables of the class which all begin with the prefix self. The draw(self) function is responsible for displaying the object on the screen. There could be many balloons and each one has its own properties, so self. refers to each individual object. |
3. get_key() and get_mouse()
You should be familiar with get_key() from the popular statement while get_key() != “esc” in the ti_system menu. Using get_key() in a loop, you can check to see which key was pressed and perform some actions accordingly. Usage: k = get_key() or k=get_key(1). If the argument 1 is used, then the program pauses and waits for a key press. If no argument is used, then the program performs all the other actions in the loop, thus making animation possible. get_mouse() is also found in the ti_system menu and is another input tool. It takes no arguments and returns the current mouse position on the screen (the tip of the arrow pointer). It returns two values: the x and y coordinates of the point on the screen using the default viewing window [where (0,0) is the upper-left corner of the screen]. Usage: x, y = get_mouse( ). These values can then be compared to objects’ (like balloons or buttons) positions on the screen. Here is some sample code from the balloon project showing the use of both functions:
k=get_key(1) top is the topmost balloon on the screen. is_clicked(x, y) is a class function (not shown) that determines if the top balloon was actually clicked. blist.pop( ) is the Python function that removes the last element from the blist. |
4. while loops and key presses
k is initialized to be an empty string to get the loop started. The loop continues until the “esc” key is pressed. Maybe. k is assigned a new value when a key is pressed. If it is the “center” key, then one of the two buttons is processed. (There’s one more detail in the program not shown here.) |
You can have a look at the complete programs in the links on each example to explain more of the coding (both the .tns file and detailed PDF document are available).
Example 1: Popped By To Ask You to Prom
Example 2: Yes! Or No?
Whatever your “prom style” may be, I hope that your students will be Nspired to take a look at these samples, make them their own or, even better, create their very own promposal and enter the contest! See you on the dance floor kids (do you still do “the twist”?).
About the author: John 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.
*Terms and conditions apply. See drawing rules on the contest site for details.
Tagcloud
Archive
- 2024
-
2023
- January (3)
- February (3)
- March (5)
- April (3)
- May (3)
- June (3)
- July (2)
-
August (6)
- 5 Ways to Spruce Up Your Classroom for Back to School
- Day of the Dog: Which Dog Is Roundest?
- Women Who Code: A TI Intern’s Fascinating STEM Journey
- 6 Sensational TI Resources to Jump-Start Your School Year
- 3 Back-to-School Math Activities to Reenergize Your Students
- A New School Year — A New You(Tube)!
- September (2)
- October (3)
- November (1)
- 2022
-
2021
- January (2)
- February (3)
- March (5)
-
April (7)
- Top Tips for Tackling the SAT® with the TI-84 Plus CE
- Monday Night Calculus With Steve Kokoska and Tom Dick
- Which TI Calculator for the SAT® and Why?
- Top Tips From a Math Teacher for Taking the Online AP® Exam
- Celebrate National Robotics Week With Supervised Teardowns
- How To Use the TI-84 Plus Family of Graphing Calculators To Succeed on the ACT®
- AP® Statistics: 6 Math Functions You Must Know for the TI-84 Plus
- May (1)
- June (3)
- July (2)
- August (5)
- September (2)
-
October (4)
- Transformation Graphing — the Families of Functions Modular Video Series to the Rescue!
- Top 3 Halloween-Themed Classroom Activities
- In Honor of National Chemistry Week, 5 “Organic” Ways to Incorporate TI Technology Into Chemistry Class
- 5 Spook-tacular Ways to Bring the Halloween “Spirits” Into Your Classroom
- November (4)
- December (1)
-
2020
- January (2)
- February (1)
- March (3)
- April (1)
- May (2)
- July (1)
- August (2)
- September (3)
-
October (7)
- Tips for Teachers in the time of COVID-19
- Top 10 Features of TI-84 Plus for Taking the ACT®
- TI Codes Contest Winners Revealed
- Best of Chemistry Activities for the Fall Semester
- Best of Biology Activities for the Fall Semester
- Best of Physics Activities for the Fall Semester
- Best of Middle Grades Science Activities
- November (1)
- December (2)
- 2019
-
2018
- January (1)
- February (5)
- March (4)
- April (5)
- May (4)
- June (4)
- July (4)
- August (4)
- September (5)
-
October (9)
- Art in Chemistry
- Which Texas Instruments (TI) Calculator for the ACT® and Why?
- Meet TI Teacher of the Month: Jessica Kohout
- Innovation in Biology
- Learning With Your Students
- A first-of-its-kind STEM strategy charts path to help educators
- #NCTMregionals Hartford 2018 Recap
- The Math Behind “Going Viral”
- Real-World Applications of Chemistry
-
November (8)
- Testing Tips: Using Calculators on Class Assessments
- Girls in STEM: A Personal Perspective
- 5 Teachers You Should Be Following on Instagram Right Now
- Meet TI Teacher of the Month: Katie England
- End-of-Marking Period Feedback Is a Two-Way Street
- #NCTMregionals Kansas City 2018 Recap
- Slope: It Shouldn’t Just Be a Formula
- Hit a high note exploring the math behind music
- December (5)
- 2017
- 2016
- 2015