0
0
Intro to Computingfundamentals~10 mins

Testing and quality assurance in Intro to Computing - 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 a message when a test passes.

Intro to Computing
if test_result == [1]:
    print("Test passed!")
Drag options to blanks, or click blank then click option'
ANone
BFalse
CTrue
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using False instead of True
Using 0 or None which mean failure or no result
2fill in blank
medium

Complete the code to raise an error if a test fails.

Intro to Computing
if not test_passed:
    raise [1]("Test failed!")
Drag options to blanks, or click blank then click option'
AIndexError
BAssertionError
CTypeError
DValueError
Attempts:
3 left
💡 Hint
Common Mistakes
Using unrelated error types like TypeError or IndexError
Not raising any error on failure
3fill in blank
hard

Fix the error in the test function to correctly check equality.

Intro to Computing
def test_sum():
    result = sum([1, 2, 3])
    assert result [1] 6
Drag options to blanks, or click blank then click option'
A==
B!=
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using != which means not equal
Using > or < which check inequality
4fill in blank
hard

Fill both blanks to create a test that checks if a number is positive.

Intro to Computing
def test_positive(num):
    assert num [1] 0 and num [2] 0
Drag options to blanks, or click blank then click option'
A>
B<
C!=
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using < instead of >
Using == instead of !=
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that filters passing scores.

Intro to Computing
passing_scores = {student: score for student, score in scores.items() if score [1] [2] and student [3] ''}
Drag options to blanks, or click blank then click option'
A>=
B60
C!=
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using < instead of >=
Using == instead of !=
Using wrong passing score value