/
Function Library
Function Library
This is a list of commonly used functions in the code portion of the Editor. If you have any questions about how they operate feel free to email us.
The complete list is available: https://quest.cns.utexas.edu/editor/code/index
Function name | Description | Argument type | Return type | Example | Default answer | Alternate answer(s) |
---|---|---|---|---|---|---|
aOrAn(num,true/false) | Returns "A" or "An" for the number when "true". Returns "a" or "an" as appropriate for the given number when "false" (or when true/false is excluded). | number and true/false | string | aOrAn(3,true) aOrAn(8,false) | "A" "an" | |
oRandom(min1,max1,min2,max2,sigfig,def) | Returns a number either between min1 and max1 or min2 and max2 with the specified number of significant digits | numbers | double | oRandom(1, 1.5, 3, 3.5, 3, 1) | 1 | 1.25, 3.3, many others |
randomStep(min,max,step,def) | Generates a random number | numbers | double | randomStep(1, 5, 1, 3) | 3 | 1, 2, 4, 5 |
reducedFrac(a,b) | Reduces a/b to simplest form | int or double | char* | reducedFrac(12,6) | 2 | |
roundoff(num, precision) | Rounds off a number Note: drops trailing zeros | numbers | string or double | roundoff(4.056, 3) x=4.02 roundoff(x, 2) | 4.06 4 | |
sigfig(num, precision) | Rounds off a number. | numbers | string | sigfig(4.056, 3) x=4.02 sigfig(x, 2) | 4.06 4.0 |
, multiple selections available,
Related content
JavaScript (JS)
JavaScript (JS)
More like this
TeX & (C or JavaScript)
TeX & (C or JavaScript)
More like this
Random Integer Function - RandomInt(min, max, pm)
Random Integer Function - RandomInt(min, max, pm)
More like this
Advanced Question Types
Advanced Question Types
More like this
Coding
More like this