Bird
0
0

What will this code print?

medium📝 Predict Output Q5 of 15
Python - Modules and Code Organization
What will this code print?
import random as r
print(r.randint(1,3))
AError: randint not found
BAlways 1
CA random number 1, 2, or 3
DA random float between 1 and 3
Step-by-Step Solution
Solution:
  1. Step 1: Understand alias and function

    random module is aliased as 'r', so r.randint(1,3) calls randint correctly.
  2. Step 2: Know randint behavior

    randint(1,3) returns a random integer 1, 2, or 3.
  3. Final Answer:

    A random number 1, 2, or 3 -> Option C
  4. Quick Check:

    randint returns random int in range [OK]
Quick Trick: randint returns random integer in given range [OK]
Common Mistakes:
  • Thinking randint returns float
  • Assuming fixed output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes