C-17-Q125mediumsingle_mcq
Compared to a long if / elif / else chain that compares one variable, a match statement is mainly used to:
Compared to a long if / elif / else chain that compares one variable, a match statement is mainly used to:
- aImprove readability when selecting based on the value of a single variable
- bReplace
forloops - cOpen files
- dPerform arithmetic
ব্যাখ্যা
match is designed to compare one subject value against several patterns, making the code cleaner than a long if/elif/else chain that repeatedly tests the same variable. Its purpose is readability for value-based selection, not looping or arithmetic.