0
0
Pythonprogramming~10 mins

Single-element tuple 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 single-element tuple with the number 5.

Python
single_element = (5[1])
Drag options to blanks, or click blank then click option'
A:
B;
C,
D.
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Forgetting the comma and writing (5) which is just a number in parentheses.
Using a semicolon or colon instead of a comma.
2fill in blank
medium

Complete the code to create a single-element tuple containing the string 'hello'.

Python
greeting = ('hello'[1])
Drag options to blanks, or click blank then click option'
A.
B,
C;
D:
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Leaving out the comma, so it is not a tuple.
Using other punctuation marks instead of a comma.
3fill in blank
hard

Fix the error in the code to correctly create a single-element tuple with the value 10.

Python
number = (10[1])
Drag options to blanks, or click blank then click option'
A:
B.
C;
D,
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using a period or colon instead of a comma.
Not adding any punctuation after the number.
4fill in blank
hard

Complete the code to create a single-element tuple with the boolean value True.

Python
flag = ([1],)
Drag options to blanks, or click blank then click option'
ATrue
BFalse
C,
D;
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using False instead of True.
Forgetting the comma after the value.
Using a semicolon instead of a comma.
5fill in blank
hard

Fill both blanks to create a single-element tuple with the float 3.14 and print its type.

Python
pi = ([1],)
print(type([2]))
Drag options to blanks, or click blank then click option'
A3.14
B,
Cpi
D3,14
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using '3,14' which is not a valid float in Python.
Forgetting the comma after the number.
Printing the number instead of the tuple variable.