IT Certifications · 98-381

Exam 98-381: Introduction to Programming Using Python Practice Test

Exam 98-381: Introduction to Programming Using Python concerns foundational Python programming: reading expressions, assigning values, and controlling program flow. The available practice bank samples topics such as strings, numbers, lists, loops, conditional expressions, and exception handling, giving learners a way to work through short code examples and predict their behavior.

Exam overview

Exam providerMicrosoft
Exam code98-381
CategoryIT Certifications

About the Exam 98-381: Introduction to Programming Using Python Exam

Python fluency at this level involves tracing how values change as statements execute and selecting syntax that expresses a task correctly. Practice with arithmetic operators such as integer division and exponentiation, comparisons, Boolean conditions, and conditional expressions. String skills include case-sensitive equality checks and extracting characters with slices. List work may involve iteration and creating a reversed copy without changing the original sequence. Loop questions ask you to identify how a `for` statement processes each item, while code-tracing tasks test accumulator patterns such as adding values to a running total. Exception-handling examples show how a `try` block and a specific `except` clause respond to errors such as division by zero. These skills support writing small scripts, checking edge cases, and explaining the output of concise Python code.

Sample Practice Questions

Review a selection from this exam's published US Practice Tests practice bank.

Question 1

What is the value of `"pear" == "Pear"`?

  1. ATrue
  2. BFalse
  3. CNone
  4. DA SyntaxError
Show answerCorrect answer: B

String equality compares characters including their case. The lowercase `p` and uppercase `P` differ, so the strings are not equal.

Question 2

What value is assigned to `status` by `status = "ready" if connected else "offline"` when `connected` is `False`?

  1. A`"ready"`
  2. B`"offline"`
  3. C`False`
  4. D`None`
Show answerCorrect answer: B

In a conditional expression, the value after `else` is selected when the condition is false. Therefore `status` becomes `"offline"`.

Question 3

Which expression evaluates to `True` if `score` is at least 60 and no greater than 100?

  1. A60 <= score <= 100
  2. Bscore < 60 or score > 100
  3. C60 < score > 100
  4. Dscore == 60 and score == 100
Show answerCorrect answer: A

Python supports chained comparisons, so `60 <= score <= 100` means both `score >= 60` and `score <= 100` must be true.

Question 4

What is the value of `7 // 2` in Python?

  1. A3
  2. B3.5
  3. C4
  4. D1
Show answerCorrect answer: A

The `//` operator performs floor division. Dividing 7 by 2 gives 3.5, and flooring that result gives 3.

Question 5

What does this code print? `try: value = 10 / 0 except ZeroDivisionError: print("cannot divide")`

  1. A`0`
  2. B`10`
  3. C`cannot divide`
  4. DNothing; the program stops before the handler
Show answerCorrect answer: C

Dividing by zero with `/` raises `ZeroDivisionError`. The matching `except` clause handles it and prints `cannot divide`.

Question 6

What is the value of `result` after this code runs? `result = 2 ** 3`

  1. A6
  2. B8
  3. C9
  4. D5
Show answerCorrect answer: B

In Python, `**` is the exponentiation operator. `2 ** 3` means 2 raised to the third power, which is 8.

Question 7

What is the value of `"python"[1:4]`?

  1. A"pyt"
  2. B"yth"
  3. C"ytho"
  4. D"tho"
Show answerCorrect answer: B

A slice includes the character at its start index and stops before its end index. Indices 1, 2, and 3 contain `y`, `t`, and `h`.

How to use this practice test

The free practice bank contains 50 questions; each session presents up to 20 randomly selected questions. Use a session to trace code, evaluate expressions, and check your understanding of Python behavior. Results appear after the session, helping you identify which question types to revisit.

Preparation tips

  • Trace each expression by hand, especially integer division, exponentiation, comparisons, and Boolean conditions.
  • Test string indexing and slicing on short examples; note that indexes start at zero and string comparisons are case-sensitive.
  • For list and loop questions, track each iteration and distinguish creating a reversed copy from modifying the original list.
  • Predict the output of accumulator code by recording the running total after each loop iteration.
  • Practice matching specific exceptions, such as `ZeroDivisionError`, with the corresponding `except` block and printed response.
Official sourceOfficial exam page ↗