Basic Programming Quiz

Questions: 16 · 10 minutes
1. A program runs: IF temperature > 30, PRINT “Hot.” If temperature equals 30 and there is no ELSE branch, what is printed?
The number 30
The word “Hot”
No message is printed
The condition automatically causes an error
2. What is a loop primarily used for?
Declaring every variable before a program starts
Choosing a data type based on user input
Repeating a block of instructions under defined conditions
Converting comments into executable instructions
3. In the function definition greet(name), what is name called?
A return value
A Boolean operator
A loop counter
A parameter
4. What does a return statement normally do inside a function?
Restarts the entire program from the beginning
Repeats the function until its input changes
Turns every local variable into a global variable
Ends the function’s current execution and can send a value back to its caller
5. When does the Boolean expression A AND B evaluate to true?
Whenever A is true, regardless of B
Whenever at least one of A or B is true
Only when A and B have different values
Only when both A and B are true
6. A program should allow entry when a person's age is 18 or greater. Which condition expresses that rule?
age is greater than or equal to 18
age is exactly equal to 18
age is strictly greater than 18
age is less than or equal to 18
7. Which data type is most appropriate for a value that can only be true or false?
String
Integer
Boolean
Floating-point number
8. What is the main purpose of an ordinary comment in source code?
To help people understand the code without acting as a normal executable instruction
To make the next instruction repeat
To store text that the program must display
To request input from the user
9. What is an algorithm?
A finite, ordered set of steps for solving a problem
A programming language used only for calculations
A list containing every possible program error
A physical component that executes source code
10. Which situation is most likely to create an unintended infinite loop?
The loop body updates the value used in its condition
The loop processes an empty collection and then stops
The loop condition stays true because the relevant value never changes
The loop condition is false before the first iteration
11. The statement PRINT(""Hello"" is missing its closing parenthesis. What kind of error is this?
A logic error
A syntax error
An input-validation error
A boundary-case error
12. A nonempty list contains several test scores. Which calculation gives its arithmetic mean?
Add the highest and lowest scores only
Add all scores and divide by the number of scores
Multiply all scores by the number of scores
Subtract the lowest score from the highest score
13. Consider this pseudocode: x ← 5, then x ← x + 2. What value does x hold afterward?
5
7
10
52
14. Trace this pseudocode: count ← 0; WHILE count < 3, set count ← count + 1; after the loop, PRINT count. What is printed?
3
2
4
Nothing, because the loop never ends
15. What is the main purpose of a variable in a program?
To translate source code into machine instructions
To store a value that the program can use or change
To repeat every instruction in the program
To detect and repair errors automatically
16. A program accepts users aged 18 or older using the condition age >= 18. Which pair of ages most directly tests the acceptance boundary?
1 and 100
18 and 50
20 and 21
17 and 18
Popular tests
Narcissistic Personality Inventory (NPI)
This self-report measure is used to assess narcissism as a personality trai…
Start Test
Yale-Brown Obsessive Compulsive Scale (Y-BOCS)
This measure is used to rapidly quantify the current severity of obsessive…
Start Test
CRAFFT Screening Test (CRAFFT 2.1)
This brief screening measure is designed to identify potential alcohol and…
Start Test
Patient Health Questionnaire-9 (PHQ-9)
This measure is commonly used to quickly screen for the presence and severi…
Start Test
Maslach Burnout Inventory (MBI)
This self-report measure is used to assess occupational burnout symptoms in…
Start Test
Adolescent Anxiety Questionnaire
This measure is designed to support a brief appraisal of anxiety symptoms a…
Start Test
Emotional Creativity Inventory (ECI)
This self-report measure assesses individual differences in the originality…
Start Test
Horne–Ostberg Morningness–Eveningness Questionnaire (MEQ)
Circadian preferences influence typical patterns of alertness and sleep tim…
Start Test
Ambivalent Sexism Inventory (ASI)
This measure is designed to assess attitudes toward women, including both o…
Start Test
Internalized Misogyny Scale (IMS)
This measure is designed to assess internalized negative beliefs and stereo…
Start Test
Perceived Stress Scale (PSS-10)
This self-report measure assesses the degree to which individuals appraise…
Start Test
Impulsive Behavior Scale (SUPPS-P)
Impulsivity is a multidimensional construct that is often assessed with bri…
Start Test
Clinical Institute Withdrawal Assessment for Alcohol, Revised (CIWA-Ar)
This rating scale is used to rapidly assess the severity of alcohol withdra…
Start Test
Positive and Negative Affect Schedule (PANAS)
This measure provides a brief self-report assessment of current or typical…
Start Test
Light Triad Scale (LTS)
This self-report measure assesses prosocial personality tendencies and orie…
Start Test
Suicidal Ideation Scale
In clinical settings, the Suicidal Ideation Scale is used to structure an i…
Start Test
Body Dysmorphic Disorder Scale (BDD-D)
This brief self-report measure is designed to screen for and quantify distr…
Start Test
Beck Anxiety Inventory (BAI)
This measure is a brief self-report inventory used to screen for anxiety sy…
Start Test
Differential Test of Perfectionism
This instrument is used to screen for perfectionism-related attitudes and t…
Start Test
Locus of Control Scale
This measure assesses generalized expectancies regarding the degree to whic…
Start Test
New Apathy Scale
This brief self-report measure is used to screen for apathy-related symptom…
Start Test
Perth Alexithymia Questionnaire (PAQ)
This measure assesses individual differences in alexithymia, including diff…
Start Test
Social Intelligence Scale
This brief self-report measure is designed to support rapid screening of in…
Start Test
Fear Test
This measure is designed to evaluate individual differences in fear-related…
Start Test
Neuroticism Level Scale
The measure is intended for brief screening of an individual’s propensity t…
Start Test
Aggressiveness Indicators Screening Questionnaire
This screening tool is designed to quickly identify behavioral indicators a…
Start Test