next up previous
Next: About this document ...

  1. (10 points) Give short answers for the following 5 questions:

  2. (10 points) Give the output for the following Python code that contains a recursive function and uses Python strings:








  3. (10 points) Give the output for the Python code segment that uses variable arguments:

  4. (10 points) Give the output for the Python code segment that uses a global variable:

  5. (10 points) The class Binary, listed below, represents a partial implementation of a binary number class. However, the code on lines 24 and 25 produce an error. Write the two functions needed so that lines 24 and 25 function properly.

    Figure 1: A GUI with text and two buttons.
    Image gui1

  6. (20 points) Write a Python program that uses a class called GUI to implement the GUI illustrated in Figure 1. When the quit button is pressed the program should ask the user if ``are you sure?'' and, if ``yes'' is pressed, the program should terminate. When the print button is pressed the program should print Hello World. The instantiation of the GUI class is illustrated below; all you have to do is import the things that you need and write the class.























    if __name__ == "__main__":
      root = Tk()
      gui = GUI(root)
      root.mainloop()
    

    Figure 2: A GUI with text and two buttons.
    Image gui2

  7. (20 points) Write a Python program that uses a class called GUI to implement the GUI illustrated in Figure 2. When the quit button is pressed the program should terminate, and when the print button is pressed the program should print Hello World. The instantiation of the GUI class is illustrated below; all you have to do is import the things that you need and write the class. You will most likely have to use grid for this program.























    if __name__ == "__main__":
      root = Tk()
      gui = GUI(root)
      root.mainloop()
    

  8. (10 points) Give the output for the Python code segment that uses a Singletone Design Pattern:




next up previous
Next: About this document ...
Brian Malloy 2007-05-31