0
0
dbtdata~10 mins

Variables and control flow in dbt - Interactive Code Practice

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

Complete the code to assign the value 10 to the variable 'limit'.

dbt
limit = [1]
Drag options to blanks, or click blank then click option'
A'10'
Blimit
C10
DNone
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the number 10 in quotes, which makes it a string.
Using the variable name on the right side instead of a value.
2fill in blank
medium

Complete the code to check if the variable 'count' is greater than 5.

dbt
{% if count [1] 5 %}
  {{'Count is greater than 5'}}
{% endif %}
Drag options to blanks, or click blank then click option'
A<
B>
C==
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' which means less than.
Using '==' which means equal to.
3fill in blank
hard

Fix the error in the loop to iterate over the list 'items'.

dbt
{% for item in [1] %}
  {{ item }}
{% endfor %}
Drag options to blanks, or click blank then click option'
Aitems
Blist
Citem_list
Ditem
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'item' which is the loop variable, not the list.
Using 'item_list' which is not defined.
4fill in blank
hard

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

dbt
{ [1]: [2] for word in words if len(word) > 3 }
Drag options to blanks, or click blank then click option'
Aword
Blen(word)
Cword.upper()
Dword.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using word.upper() or word.lower() as keys which changes the word.
Using word instead of len(word) for the value.
5fill in blank
hard

Fill all three blanks to create a dictionary with uppercase keys and values only if value is greater than 0.

dbt
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.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using k.lower() instead of k.upper().
Using '<' or '==' instead of '>' in the condition.