0
0
Testing Fundamentalstesting~10 mins

Test prioritization in Testing Fundamentals - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to print the highest priority test case first.

Testing Fundamentals
test_cases = [('Login', 3), ('Signup', 1), ('Checkout', [1])]
sorted_tests = sorted(test_cases, key=lambda x: x[1])
print(sorted_tests[0][0])
Drag options to blanks, or click blank then click option'
A2
B5
C1
D4
Attempts:
3 left
💡 Hint
Common Mistakes
Using a priority number that is too high or too low, causing wrong order.
Not understanding that lower numbers mean higher priority.
2fill in blank
medium

Complete the code to filter only high priority tests (priority less than 3).

Testing Fundamentals
test_cases = [('Login', 3), ('Signup', 1), ('Checkout', 2)]
high_priority = [test for test in test_cases if test[1] [1] 3]
print(high_priority)
Drag options to blanks, or click blank then click option'
A>
B==
C<
D>=
Attempts:
3 left
💡 Hint
Common Mistakes
Using > instead of < causing wrong tests to be selected.
Using equality operator which only selects priority exactly 3.
3fill in blank
hard

Fix the error in the code to correctly sort tests by priority ascending.

Testing Fundamentals
test_cases = [('Login', 3), ('Signup', 1), ('Checkout', 2)]
sorted_tests = sorted(test_cases, key=lambda x: x[[1]])
print([test[0] for test in sorted_tests])
Drag options to blanks, or click blank then click option'
A1
B2
C0
D-1
Attempts:
3 left
💡 Hint
Common Mistakes
Using index 0 which sorts by test name, not priority.
Using index 2 which is out of range and causes error.
4fill in blank
hard

Fill both blanks to create a dictionary of test names and their priorities, filtering only tests with priority {{BLANK_1}} 2 and {{BLANK_2}} 4.

Testing Fundamentals
test_cases = [('Login', 3), ('Signup', 1), ('Checkout', 2), ('Profile', 4)]
filtered = {test[0]: test[1] for test in test_cases if test[1] [1] 2 and test[1] [2] 4}
print(filtered)
Drag options to blanks, or click blank then click option'
A>=
B<=
C==
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using equality operators which select only exact values.
Using wrong comparison directions causing empty results.
5fill in blank
hard

Fill all three blanks to create a list of test names with priority {{BLANK_1}} 3, sorted by priority {{BLANK_2}} and then by name {{BLANK_3}}.

Testing Fundamentals
test_cases = [('Login', 3), ('Signup', 1), ('Checkout', 3), ('Profile', 2)]
sorted_tests = sorted(test_cases, key=lambda x: (x[1], x[0]), reverse=[1])
result = [test[0] for test in sorted_tests if test[1] [2] 3]
print(result)
Drag options to blanks, or click blank then click option'
AFalse
BTrue
C==
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using reverse=True which sorts descending, not desired here.
Using wrong comparison operators causing wrong filtering.