Advertisement
MrsMcLead

ECS readnum

Nov 19th, 2013
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.61 KB | None | 0 0
  1. from tkinter import*
  2. import tkinter.simpledialog
  3. import tkinter.messagebox
  4.  
  5. root = Tk()
  6. w = Label(root, text="Read Numbers")
  7. w.pack()
  8.  
  9. str1 = tkinter.simpledialog.askstring("String", "Please enter a STRING.")
  10. num1 = tkinter.simpledialog.askinteger("Integer", "Please enter an INTEGER.")
  11. num2 = tkinter.simpledialog.askfloat("Float", "Please enter a FLOAT.")
  12.  
  13. tkinter.messagebox.showinfo("Output", "You entered:\nSTRING: " + str1 +
  14.                       "\nINTEGER: " + str(num1) + "\nFLOAT: " + str(num2))
  15.  
  16.  
  17. # Turn in your answers to these questions in this file.
  18. # Be careful to follow the directions closely.
  19. #
  20. #  1.  Build and Run the program and enter the following:
  21. #       enter a STRING: 5
  22. #       enter an INTEGER: 5
  23. #       enter a FLOAT: 5
  24. #      
  25. #      What is output at the end?  
  26. #
  27. #  2.  Run the program.  What happens if you TRY to enter the following:
  28. #       enter a STRING: x
  29. #       enter an INTEGER: x
  30. #       enter a FLOAT: 5.0
  31. #
  32. #  3.  Run the program.  What happens if you TRY to enter the following:
  33. #       enter a STRING: x
  34. #       enter an INTEGER: 5
  35. #       enter a FLOAT: x
  36. #
  37. #  4.  Run the program.  What happens if you TRY to enter the following:
  38. #       enter a STRING: 3.4
  39. #       enter an INTEGER: 3.4
  40. #       enter a FLOAT: 3.4
  41. #
  42. #  5.  What can you type in for a STRING?
  43. #  6.  What can you type in for an INTEGER?
  44. #  7.  What can you type in for a FLOAT?
  45. #  8.  What's the difference between an integer and a float?
  46. #  9   In the tkMessageBox.showinfo(), what is written before (num1) and (num2)?
  47. # 10.  Why do you think python might want to treat numbers differently
  48. #      than words?  (Hint: what can you do with numbers?)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement