0
0
Testing Fundamentalstesting~10 mins

Condition coverage 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 check if the number is positive.

Testing Fundamentals
def is_positive(num):
    if num [1] 0:
        return True
    else:
        return False
Drag options to blanks, or click blank then click option'
A>
B!=
C<
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' instead of '>' will only check if the number equals zero.
Using '<' checks for negative numbers, not positive.
2fill in blank
medium

Complete the code to test if a string is empty.

Testing Fundamentals
def is_empty(s):
    if len(s) [1] 0:
        return True
    else:
        return False
Drag options to blanks, or click blank then click option'
A!=
B>
C==
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '!=' would check if the string is not empty.
Using '>' or '<' would not correctly identify an empty string.
3fill in blank
hard

Fix the error in the condition to check if a number is even.

Testing Fundamentals
def is_even(n):
    if n [1] 2 == 0:
        return True
    else:
        return False
Drag options to blanks, or click blank then click option'
A+
B//
C*
D%
Attempts:
3 left
💡 Hint
Common Mistakes
Using '//' performs integer division, not remainder.
Using '*' or '+' are arithmetic operations that don't check evenness.
4fill in blank
hard

Fill both blanks to create a condition that checks if a number is between 10 and 20 inclusive.

Testing Fundamentals
def in_range(x):
    if x [1]= 10 and x [2]= 20:
        return True
    else:
        return False
Drag options to blanks, or click blank then click option'
A>
B<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '<=' excludes 20 from the range.
Using '>' instead of '>=' excludes 10 from the range.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps words to their lengths only if length is greater than 3.

Testing Fundamentals
words = ['apple', 'bat', 'carrot', 'dog']
lengths = { [1]: [2] for word in words if [3] > 3 }
Drag options to blanks, or click blank then click option'
Aword
Blen(word)
Attempts:
3 left
💡 Hint
Common Mistakes
Using the length as the key instead of the word.
Not using the length in the condition to filter words.