0
0
Pythonprogramming~10 mins

Tuple creation in Python - Interactive Code Practice

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

Complete the code to create a tuple with three numbers.

Python
my_tuple = (1, 2, [1])
Drag options to blanks, or click blank then click option'
A"3"
B[3]
C{3}
D3
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using square brackets [] which create a list, not a tuple.
Using curly braces {} which create a set, not a tuple.
Putting the number inside quotes which makes it a string.
2fill in blank
medium

Complete the code to create a tuple with a single element.

Python
single_element_tuple = ([1],)
Drag options to blanks, or click blank then click option'
A"5"
B5
C[5]
D5,
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Forgetting the comma, which makes it just a number in parentheses, not a tuple.
Using a list instead of a tuple.
Putting the number inside quotes making it a string.
3fill in blank
hard

Fix the error in the tuple creation code.

Python
my_tuple = [1] 1, 2, 3)
Drag options to blanks, or click blank then click option'
A(
B[
C((
D{
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using double parentheses which is invalid here.
Using square or curly brackets which create lists or sets.
Missing the opening parenthesis.
4fill in blank
hard

Fill both blanks to create a tuple with two strings.

Python
names = ([1], [2])
Drag options to blanks, or click blank then click option'
A"Alice"
BAlice
C"Bob"
DBob
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Leaving out quotes which makes Python look for variables named Alice or Bob.
Mixing quoted and unquoted names.
Using single quotes inconsistently (allowed but here we use double quotes).
5fill in blank
hard

Fill all three blanks to create a tuple with mixed types: string, integer, and float.

Python
mixed = ([1], [2], [3])
Drag options to blanks, or click blank then click option'
A"score"
B10
C3.14
D'score'
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using quotes around numbers which makes them strings.
Using single quotes inconsistently.
Leaving out quotes around the string.