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="Read Numbers")
- w.pack()
- str1 = tkinter.simpledialog.askstring("String", "Please enter a STRING.")
- num1 = tkinter.simpledialog.askinteger("Integer", "Please enter an INTEGER.")
- num2 = tkinter.simpledialog.askfloat("Float", "Please enter a FLOAT.")
- tkinter.messagebox.showinfo("Output", "You entered:\nSTRING: " + str1 +
- "\nINTEGER: " + str(num1) + "\nFLOAT: " + str(num2))
- # Turn in your answers to these questions in this file.
- # Be careful to follow the directions closely.
- #
- # 1. Build and Run the program and enter the following:
- # enter a STRING: 5
- # enter an INTEGER: 5
- # enter a FLOAT: 5
- #
- # What is output at the end?
- #
- # 2. Run the program. What happens if you TRY to enter the following:
- # enter a STRING: x
- # enter an INTEGER: x
- # enter a FLOAT: 5.0
- #
- # 3. Run the program. What happens if you TRY to enter the following:
- # enter a STRING: x
- # enter an INTEGER: 5
- # enter a FLOAT: x
- #
- # 4. Run the program. What happens if you TRY to enter the following:
- # enter a STRING: 3.4
- # enter an INTEGER: 3.4
- # enter a FLOAT: 3.4
- #
- # 5. What can you type in for a STRING?
- # 6. What can you type in for an INTEGER?
- # 7. What can you type in for a FLOAT?
- # 8. What's the difference between an integer and a float?
- # 9 In the tkMessageBox.showinfo(), what is written before (num1) and (num2)?
- # 10. Why do you think python might want to treat numbers differently
- # than words? (Hint: what can you do with numbers?)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement