Skip to content

Numeric Answer Question

The numeric answer question resource creates questions that expect numerical responses. These questions support exact values, ranges, and precision validation for mathematical calculations and quantitative assessments.

resource "numeric_answer_question" "name" {
question = "How many CPU cores does a t3.medium EC2 instance have?"
answer = 2
}
resource "numeric_answer_question" "name" {
question = "What is the default HTTP port for web servers?"
answer = 80
hints = [
"This is a well-known port number",
"Most web browsers use this port by default"
]
tags = ["networking", "http", "ports"]
}

numeric_answer_question

FieldRequiredTypeDescription
questionstringThe question text presented to participants
answernumberThe correct numerical answer
hintslist(string)Hints shown to participants when hints are enabled. Defaults to empty list.
tagslist(string)Tags for categorizing and organizing questions. Defaults to empty list.

Numeric questions require participants to enter the exact value specified in the answer field.

resource "numeric_answer_question" "kubernetes_port" {
question = "What is the default port for the Kubernetes API server?"
answer = 6443
tags = ["kubernetes", "networking", "api"]
}
resource "numeric_answer_question" "memory_calculation" {
question = "How many gigabytes of RAM does a server with 8192 MB have? (Round to nearest whole number)"
answer = 8
hints = [
"Convert megabytes to gigabytes",
"1024 MB = 1 GB"
]
tags = ["memory", "calculations", "conversions"]
}
resource "numeric_answer_question" "pod_replicas" {
question = "If you have 3 worker nodes and want to distribute 9 pod replicas evenly, how many pods per node?"
answer = 3
tags = ["kubernetes", "scaling", "calculations"]
}

The following defaults are applied automatically:

resource "numeric_answer_question" "name" {
hints = []
tags = []
}
  • Number format: Answers must be valid integers or decimal numbers
  • Exact match: Participant input must exactly match the specified answer value
  • Input validation: Participant inputs are validated as numbers before comparison

Numeric answer questions are referenced in quiz resources:

resource "quiz" "technical_calculations" {
questions = [
resource.numeric_answer_question.kubernetes_port,
resource.numeric_answer_question.memory_calculation,
resource.numeric_answer_question.pod_replicas
]
show_hints = true
attempts = 2
}
  1. Clear Units: Specify units in the question (MB, GB, seconds, etc.)
  2. Precise Values: Ensure the expected answer is clearly defined
  3. Context Clarity: Provide enough context for participants to understand what to calculate
  4. Realistic Numbers: Use practical values that participants might encounter
  5. Helpful Hints: Guide the calculation process without giving away the answer
  6. Educational Value: Use explanations to reinforce the underlying concepts
  7. Input Validation: Consider what formats participants might use (decimals, integers)
  8. Avoid Trick Questions: Focus on knowledge and understanding, not mathematical gotchas