Prompt(float)
Also see :
Quick Notes |
- floating point number (a built-in Python object type)
- param (module from which Prompt is imported)
- Using a text editor
Example :
The Prompt() function in this example defines a float prompt because the first argument -- 14.25 -- is a floating point number . Pressing " OK " on the dialog returns the floating point equivalent to the numerical value that is entered, even if the user enters an integer . Pressing " Cancel " returns ResponseNotOK .
# Converts decimal inches to ft-in frac and millimeters.
from param import Prompt, ResponseNotOK, Units, dim_print
Units("feet") # sets dim_print output to ft-in frac
try:
inches = Prompt(14.25, "Enter decimal inches:")
mm = inches * 25.4
print("The value (inches) you entered =", inches)
print("The value in ft-in frac =", dim_print(inches))
print("The value in millimeters =", mm)
except ResponseNotOK: # user presses "Cancel"
pass