0
0
Testing Fundamentalstesting~10 mins

Data validation rules 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 input is not empty.

Testing Fundamentals
if [1]:
Drag options to blanks, or click blank then click option'
Ainput_value
Bnot input_value
Cinput_value == ''
Dinput_value is None
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'not input_value' which checks for empty instead of non-empty.
Comparing input_value to empty string explicitly.
2fill in blank
medium

Complete the code to validate that age is a positive integer.

Testing Fundamentals
if isinstance(age, int) and age [1] 0:
Drag options to blanks, or click blank then click option'
A==
B<=
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<=' which allows zero or negative numbers.
Using '==' which only allows age exactly zero.
3fill in blank
hard

Fix the error in the validation that checks if email contains '@'.

Testing Fundamentals
if [1] email:
Drag options to blanks, or click blank then click option'
Aemail.index
B'@' in
Cemail.contains
Demail.find
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'email.contains' which is not a valid string method in Python.
Using 'email.find' incorrectly as a function call.
4fill in blank
hard

Fill both blanks to validate a username: it must be a string and at least 3 characters long.

Testing Fundamentals
if isinstance(username, [1]) and len(username) [2] 3:
Drag options to blanks, or click blank then click option'
Astr
B>=
Cint
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Checking for int type instead of str.
Using '<' which checks for less than 3 characters.
5fill in blank
hard

Fill all three blanks to create a dictionary of valid scores greater than 50.

Testing Fundamentals
valid_scores = [1]: [2] for [1], [2] in scores if [2] > 50}
Drag options to blanks, or click blank then click option'
Aplayer
Bscore
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up keys and values in the dictionary comprehension.
Using the wrong variable names for filtering.