0
0
Testing Fundamentalstesting~10 mins

Skills for modern testers 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 define a test case that checks if a function returns the expected result.

Testing Fundamentals
def test_addition():
    result = add(2, 3)
    assert result == [1]
Drag options to blanks, or click blank then click option'
A5
B6
C4
D7
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong expected value in the assertion.
Forgetting to use assert to check the result.
2fill in blank
medium

Complete the code to check if a list contains a specific element.

Testing Fundamentals
def test_contains_element():
    items = ['apple', 'banana', 'cherry']
    assert [1] in items
Drag options to blanks, or click blank then click option'
A'melon'
B'orange'
C'grape'
D'banana'
Attempts:
3 left
💡 Hint
Common Mistakes
Checking for an element not present in the list.
Forgetting to put quotes around the string.
3fill in blank
hard

Fix the error in the test function to correctly check if a number is even.

Testing Fundamentals
def test_is_even():
    number = 8
    assert number [1] 2 == 0
Drag options to blanks, or click blank then click option'
A%
B+
C-
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition or multiplication instead of modulo.
Checking equality incorrectly.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps words to their lengths for words longer than 3 characters.

Testing Fundamentals
lengths = {word: [1] for word in words if len(word) [2] 3}
Drag options to blanks, or click blank then click option'
Alen(word)
B<=
C>
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word itself as the value instead of its length.
Using the wrong comparison operator.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase keys to their values for items with positive values.

Testing Fundamentals
result = [1]: [2] for k, v in data.items() if v [3] 0
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
C>
Dk
Attempts:
3 left
💡 Hint
Common Mistakes
Using the original key instead of uppercase.
Using wrong comparison operator or filtering condition.