Exercises
Here are some exercises for you to try on your own. Solutions are available
at http://pragprog.com/titles/gwpy3/practical-programming.
-
Write a GUI application with a button labeled “Goodbye.” When
the button is clicked, the window closes.
-
Write a GUI application with a single button. Initially the button is
labeled 0, but each time it is clicked, the value on the button increases
by 1.
-
What is a more readable way to write the following?
-
A DNA sequence is a string made up of As, Ts,
Cs, and Gs. Write a GUI application in which a
DNA sequence is entered, and when the Count button is clicked, the number
of As, Ts, Cs, and Gs
are counted and displayed in the window (see the following image).
-
In Defining Our Own Functions, we wrote a function to
convert degrees Fahrenheit to degrees Celsius. Write a GUI application
that looks like the following image.
When a value is entered in the text field and the Convert button is
clicked, the value should be converted from Fahrenheit to Celsius and
displayed in the window, as shown in the following image.
-
Rewrite the text editor code from Using Menu, as an
object-oriented GUI.
Copyright © 2017, The Pragmatic Bookshelf.