Bird
0
0

Given this Python retry snippet for DynamoDB, what will be the output if the first two attempts raise ProvisionedThroughputExceededException and the third succeeds?

medium📝 Predict Output Q4 of 15
DynamoDB - with AWS SDK
Given this Python retry snippet for DynamoDB, what will be the output if the first two attempts raise ProvisionedThroughputExceededException and the third succeeds? ```python retry_count = 0 while retry_count < 3: try: # DynamoDB call here print('Success') break except ProvisionedThroughputExceededException: print(f'Retry {retry_count}') retry_count += 1 ```
ARetry 0 Retry 1 Success
BRetry 1 Retry 2 Success
CRetry 0 Retry 1 Retry 2 Success
DSuccess
Step-by-Step Solution
Solution:
  1. Step 1: Trace retry_count and output on exceptions

    First attempt fails: prints 'Retry 0', retry_count=1. Second fails: 'Retry 1', retry_count=2.
  2. Step 2: Third attempt succeeds and prints 'Success'

    Loop breaks after printing 'Success'.
  3. Final Answer:

    Retry 0 Retry 1 Success -> Option A
  4. Quick Check:

    Output matches retries then success [OK]
Quick Trick: Count retries from zero and print before increment [OK]
Common Mistakes:
MISTAKES
  • Starting retry count at 1 instead of 0
  • Printing retry count after increment
  • Assuming all retries print before success

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More DynamoDB Quizzes