-
Notifications
You must be signed in to change notification settings - Fork 0
Numerical Input
Homer Haddock edited this page Sep 28, 2024
·
1 revision
Integers are best used for questions like "How old are you?" where a decimal is not needed.
newLineInt can be used in two ways.
import inputapi as inp
# Method 1
inp.newLineInt()
# Method 2
inp.numerical.integer.newLineInt()| Parameter | data type | default | Purpose it serves |
|---|---|---|---|
| request | string | "Input an integer:" |
What the user will see when the input is requested |
| allowNeg | boolean | True |
Determines if the user can give a negative number |
| min | integer | No limit | What is the lowest number allowed |
| max | integer | No limit | What is the highest number allowed |
| clearOnLoad | boolean | False |
When the function is run, should the terminal be cleared |
| clearWhenDone | boolean | False |
When the input is retrieved, should the terminal be cleared |
This input has only one way of being used.
import inputapi as inp
inp.numerical.integer.sameLineInt()| Parameter | data type | default | Purpose it serves |
|---|---|---|---|
| request | string | "Integer=" |
What the user will see when the input is requested |
| allowNeg | boolean | True |
Determines if the user can give a negative number |
| min | integer | No limit | What is the lowest number allowed |
| max | integer | No limit | What is the highest number allowed |
| clearOnLoad | boolean | False |
When the function is run, should the terminal be cleared |
| clearWhenDone | boolean | False |
When the input is retrieved, should the terminal be cleared |
Floating point input is great for accuracy (e.g. distance).
Here is how you can use newLineFloat in Python.
import inputapi as inp
# Method 1
inp.newLineFloat()
# Method 2
inp.numerical.float.newLineFloat()| Parameter | data type | default | Purpose it serves |
|---|---|---|---|
| request | string | "Input an floating point number (Decimal):" |
What the user will see when the input is requested |
| allowNeg | boolean | True |
Determines if the user can give a negative number |
| min | integer | No limit | What is the lowest number allowed |
| max | integer | No limit | What is the highest number allowed |
| clearOnLoad | boolean | False |
When the function is run, should the terminal be cleared |
| clearWhenDone | boolean | False |
When the input is retrieved, should the terminal be cleared |
Only one way to use sameLineFloat.
import inputapi as inp
inp.numerical.float.sameLineFloat()| Parameter | data type | default | Purpose it serves |
|---|---|---|---|
| request | string | "Decimal=" |
What the user will see when the input is requested |
| allowNeg | boolean | True |
Determines if the user can give a negative number |
| min | integer | No limit | What is the lowest number allowed |
| max | integer | No limit | What is the highest number allowed |
| clearOnLoad | boolean | False |
When the function is run, should the terminal be cleared |
| clearWhenDone | boolean | False |
When the input is retrieved, should the terminal be cleared |