6.16 Working with Variable Data - Maple T.A. 2016 Help
Maple T.A. Online Help

Instructor
Search Maple T.A. 2016 Help:

6.16 Working with Variable Data

For each type of question supported, you can include algorithmically generated (random) variables in question statements, answers, hints, and feedback. Using variables in questions, you can generate variations on a single template question.

Types of Variables

  • Range-based variables: You can specify mathematical ranges (set by declaring minimum and maximum data values and increments for randomly generated data). Range-based variables are defined by a formula, and can include mathematical operations. For example, you can specify a variable x that is a random integer between 0 and 30, in steps of 3, using the variable definition: $x=range(0,30,3). See the tutorial on this topic, Tutorial: Algorithmic Question.

  • List-based variables: You can randomly select a set of data from lists, and present to students a scenario with related variables. For example, you can create an astronomy question that randomly selects a planet in our solar system, and then automatically assigns the acceleration due to gravity at the planet's surface to the answer variable. See the tutorial on this topic, Tutorial: List-based Variables.

You can use more than one type of variable in a question. You can use any combination.

You can place conditions on variables. For example, you can specify that the value of a variable not exceed that of another.

Note: You can create or edit variables and algorithmically generated data using the Algorithm Designer in the Question Editor. Alternatively, you can create questions without variable data using the Question Editor, and then export the plain-text script file (with the file extension .qu) to your hard drive. Add variables by editing the questions directly in your text or HTML editor.

See Also:

Generating Random Numbers in Questions

Mathematical and Logical Operators in Algorithms and Answers

The Algorithm Designer

Functions within Algorithms

Algorithmic definitions of variables are of the form:

qu.x.y.algorithm=
$variable1=expression;
$variable2=expression;
@
  • The use of the semicolon at the end of the variable definition is optional if there is only one variable defined in the algorithm statement.
  • The syntax of formulas and the use of operators in variable definition statements is similar to the standard graphing calculator syntax used in the system, with the addition of some new functions. Therefore, the system's usual arithmetic operations and functions can be used in the expression portion of the code statement.
  • However, unlike most other programming languages, variables cannot be redefined in terms of themselves (for example, the statement $a=$a+1; is invalid).

The following additional functions and operations are also available for use in variable definitions in algorithms.

Random Number Functions

Random integer generation (integers in a specified range, in steps of k):

Random real number generation (to k significant digits):

Operations and Modifiers

condition:x

See condition:x

eq(a, b)

ne(a,b)

See eq(a, b), ge(a, b), le(a, b), ne(a, b)

not(a)

See not(a)

gt(a, b)

lt(a, b)

See gt(a, b), lt(a, b)

if(a, b, c)

See if(a, b, c)

decimal(n, x)

int(x)

 

sig(n, x)

See decimal(n, x), sig(n, x), int(x)

lsu(n, x)

See lsu(n, x)

sum(varname, start, stop, expr)

See sum(var name, start, stop, expr)

switch(n, a, b, c, ...)

See switch(n, a, b, c, ...)

See Also:

Rules for Naming Variables

Inline Variable Expressions

You can include a computed expression anywhere within a question statement, comment, or hint.

  • Inline variable expressions can contain computations involving functions or algorithmic variables defined elsewhere in the question.
  • The syntax is to enclose the expression in ${...}.

For example, you can include expressions like ${$n + 1} in place of defining a separate variable to hold n+1. This simplifies complex algorithms.

Example

qu.1.1.question=
  What is the derivative of x^$n?
@
qu.1.1.answer=
  $n x^${$n-1}
@
qu.1.1.algorithm=
  $n=range(2,10);
@ 

See Also:

mathml(f)

Inline Display of Formatted Math Expressions

Simplified Math Expressions

Rules for Naming Variables

Follow these rules when naming variables:

  • A variable name must be of the form $name or ${name}.
  • The string name can consist of letters (a-z and A-Z), numbers (0-9), and underscore characters (_).
  • The first character of name must be an alphabetic character (a-z or A-Z).
  • If the ${name} form is used, spaces can also appear in name. This allows you to use multiple word names without the underscore character.

Note: The variable e should not be assigned as a global variable in Maple code. It can be used, however, as a local variable.

See Also:

Functions within Algorithms