Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- import tkinter.simpledialog
- import tkinter.messagebox
- root = Tk()
- w = Label(root, text="Lists")
- w.pack()
- names = ["", "", "", ""]
- tkinter.messagebox.showinfo("Get Ready", "I'm going to ask you for 4 names")
- names[0] = tkinter.simpledialog.askstring("Name 1", "Please enter first name")
- names[1] = tkinter.simpledialog.askstring("Name 2", "Please enter second name")
- names[2] = tkinter.simpledialog.askstring("Name 3", "Please enter third name")
- names[3] = tkinter.simpledialog.askstring("Name 4", "Please enter fourth name")
- tkinter.messagebox.showinfo("Reversed", "Here are the names in the reverse order:\n" +
- names[3] + "\n" +
- names[2] + "\n" +
- names[1] + "\n" +
- names[0] + "\n")
- # This file deals with List. You can think of them as a cupboard with different
- # numbered shelves to store things. Run the file. Answer the
- # questions below.
- # 1. On the line:
- # names = ["", "", "", ""]
- #
- # What symbols surround all the quotes?
- #
- # 2. On the line:
- # names = ["", "", "", ""]
- #
- # How many sets of quotes are there?
- #
- # 3. On the line:
- # names[0] = tkSimpleDialog.askstring("Name 1", "Please enter first name")
- #
- # Why do you think the 0 is for?
- #
- # 4. Why do you think the names are output in the reverse order that you entered them?
- # 5. Make the code ask for a fifth name. Write down the changes you made.
- # 6. Have the code output the fifth name with the others. Write down what you did.
- # 7. Get the code to print the names in the original order that they were entered.
- # Write down the changes you made.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement