Back to the Introduction to Computer Science outline The Course Maker
Introduction to Computer Science outline
Week 2 · Quiz

Week 2 — Quiz (auto-graded) · Variables, Data Types & Expressions

Introduction to Computer Science · CSCI 1101 Fall 2026 · Prof. Okafor Fictional sample

Course: Introduction to Computer Science — CS1 / Programming Fundamentals in Python (CSCI 1101) · Silver Oak University (fictional sample) · Prof. Okafor
Objective tested: Objective 2 — variables; the four core types; type(); expressions & precedence; / vs // vs %; type conversion.
Points: 10 (1 each) · Assignment group: Quizzes (10% of grade) · Due: end of Module 2.

This is the human-readable quiz with its vetted answer key and feedback. The import-ready Classic QTI is in F-quiz-week-02-qti.xml (generated by the shared validated script — parses with 10 items, every single-answer item exactly one correct). Execution gate: PASS — every "what does this print?" key below was produced by actually running the code in Python, not hand-traced. The Canvas placement block is at the bottom of this file.


Blueprint

# Type Concept Objective
1 Multiple choice What = does (assignment, not comparison) 2
2 Multiple choice Predict the output — reassignment (x = 5; x = 8) 2
3 Multiple choice Predict the output — operator precedence (2 + 3 * 4) 2
4 Multiple choice Predict the output — true division is a float (10 / 2) 2
5 Multiple choice Predict the output — floor division (7 // 2) 2
6 Multiple choice Predict the output — modulo (7 % 2) 2
7 Multiple answer True statements about types and operators 2
8 Multiple choice Debugging — fix the "5" + 3 TypeError 2
9 True / False type(5.5) is <class 'float'> 2
10 Matching Operator → result (7 // 2, 7 / 2, 7 % 2, 2 ** 3) 2

No trick questions; distractors are plausible mis-traces (treating / as whole-number division, // as rounding, string-vs-number confusion, left-to-right arithmetic).


Questions, key, and feedback

Q1 (MC). In Python, what does the line score = 10 do?
- A. It checks whether score is equal to 10
- B. It stores the value 10 in a variable named score
- C. It prints 10 to the screen
- D. It creates an error, because you can't use = like that
Feedback: A single = is the assignment operator — it puts a value in a variable ("score gets 10"). Comparing for equality is == (Week 4); printing needs print(...). (Read = as "put this value in the box.")

Q2 (MC). What does this program print?

x = 5
x = 8
print(x)
  • A. 5
  • B. 8
  • C. 58
  • D. 13
    Feedback: Reassignment replaces the value, so the box x holds the most recent one: 8. A variable holds exactly one value at a time. (Run-verified: prints 8.)

Q3 (MC). What does this program print?

print(2 + 3 * 4)
  • A. 20
  • B. 14
  • C. 24
  • D. 9
    Feedback: Operator precedence: multiplication before addition, so 3 * 4 = 12, then 2 + 12 = 14not left-to-right (which would wrongly give 20). (Run-verified: 14.)

Q4 (MC). What does this program print?

print(10 / 2)
  • A. 5
  • B. 5.0
  • C. 2.0
  • D. an error
    Feedback: True division / always returns a float, even when it divides evenly — so 10 / 2 is 5.0, not 5. (If you want the whole number 5, use //.) (Run-verified: 5.0. This is the week's #1 surprise.)

Q5 (MC). What does this program print?

print(7 // 2)
  • A. 3.5
  • B. 3
  • C. 4
  • D. 1
    Feedback: Floor division // divides and keeps only the whole-number part (it drops the fraction, it does not round up), so 7 // 2 is 3. (3.5 would be /; 1 would be %. Run-verified: 3.)

Q6 (MC). What does this program print?

print(7 % 2)
  • A. 3
  • B. 1
  • C. 3.5
  • D. 0
    Feedback: Modulo % gives the remainder after division: 7 divided by 2 is 3 with 1 left over, so 7 % 2 is 1. (3 would be //; 3.5 would be /. Run-verified: 1.)

Q7 (Multiple answer — select all that apply). Which of the following statements are true?
- A. The value 5.5 has type float
- B. The / operator always returns a float (e.g. 10 / 2 is 5.0)
- C. // rounds the result to the nearest whole number
- D. Text inside quotation marks, like "Sam", has type str
- E. = compares two values to see if they are equal
Feedback: 5.5 is a float (A); / always yields a float (B); quoted text is a str (D). C is false// floors (drops the fraction), it doesn't round. E is false= assigns; == compares.

Q8 (MC). This program crashes with TypeError: can only concatenate str (not "int") to str:

print("5" + 3)

What is the best fix so it prints 8?
- A. print(int("5") + 3)
- B. print("5" + "3")
- C. print("5" + str(3))
- D. Nothing — it already prints 8
Feedback: "5" is a string and 3 is an int, so + can't combine them — that's the TypeError. Converting with int("5") makes it the number 5, and 5 + 3 prints 8. (B prints 53 — string join; C prints 53 too — both join text, not add. Run-verified: int("5") + 38.)

Q9 (True / False). print(type(5.5)) displays <class 'float'>.
- True
- False
Feedback: True. 5.5 has a decimal point, so its type is float, and type() reports <class 'float'>. (A whole number like 5 would be <class 'int'>.) Run-verified.

Q10 (Matching). Match each expression to the value Python prints when you run it.
| Expression | Correct result |
|---|---|
| 7 // 2 | 3 |
| 7 / 2 | 3.5 |
| 7 % 2 | 1 |
| 2 ** 3 | 8 |
Feedback: // floors → 3; / is true division → 3.5; % is the remainder → 1; ** is exponent → 2 ** 3 = 8. The four arithmetic operators that trip up beginners, side by side. (All four run-verified.)


Answer key (quick reference)

Q Answer
1 B
2 B (8)
3 B (14)
4 B (5.0)
5 B (3)
6 B (1)
7 A, B, D
8 A (int("5") + 3)
9 True
10 7 // 23 / 7 / 23.5 / 7 % 21 / 2 ** 38

Quality gate (self-checked): each single-answer item has exactly one correct option; the multiple-answer item keys A, B, D (and requires C and E unselected); the matching item pairs four expressions to four distinct results. Execution gate: PASS — the keys for the predict-the-output items (Q2 8; Q3 14; Q4 5.0; Q5 3; Q6 1), the conversion item (Q8 int("5") + 38), the type item (Q9 <class 'float'>), and all four matching pairs (Q10) were each produced by running the code in Python, not hand-traced. Distractors are plausible mis-traces (Q4 5 = treating / as whole-number division; Q5 4 = rounding instead of flooring; Q8 B/C = joining strings instead of adding numbers).


Item-bank entries (for variants + the midterm/final)

All ten items are tagged course=CSCI1101 · week=2 · objective=2 · topic=variables-types-and-expressions and deposited in Item Bank: Week 2 — Variables, Data Types & Expressions. The midterm (Week 8) and the per-term variant updates draw fresh items from this bank. (Tags: q1 assignment, q2 reassignment, q3 precedence, q4 true-division-float, q5 floor-division, q6 modulo, q7 true-statements, q8 typeerror-fix, q9 type-float, q10 operator-match.)

Canvas placement block

canvas_object   = Quizzes::Quiz
title           = "Week 2 Quiz — Variables, Data Types & Expressions"
assignment_group = "Quizzes"
points_possible = 10
grading_type    = points
due_offset_days = 5        # 5 days after module start (Sun Sep 13)
published       = true
shuffle_answers = true
ai_permitted    = false    # AI is not permitted on quizzes
provenance      = "~ Prof. Okafor's edition · Fall 2026 · built with thecoursemaker.com"
This is the human-readable quiz with its vetted answer key and rationale. The import-ready Classic-QTI version (F-quiz-week-02-qti.xml) ships inside the course's .imscc package — it lands in the Canvas gradebook on import.

~ Prof. Okafor's edition · Fall 2026 · built with thecoursemaker.com