Skip to main content
🔒 Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the rest of the curriculum. Card required, cancel any time in Dashboard.Start 7-day trial →
← CoursesPython FoundationsModule 8 · Modern Python and capstoneargparse mini-CLIpredict167 / 174
+100 XP
Task
📝 **Question:** Predict the output. The args list has \`--shout\` so \`args.shout\` is True and the greeting is upper-cased. 📋 Pick the right answer. 💡 **Hint:** Re-read the theory above if unsure.
Predict the output

Read the code carefully

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("name")
parser.add_argument("--shout", action="store_true")
args = parser.parse_args(["Ada", "--shout"])

msg = f"hi {args.name}"
print(msg.upper() if args.shout else msg)

What will the program print? Write here:

💬 Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…