0
0
Pythonprogramming~10 mins

print() parameters and formatting 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 print the words separated by a space.

Python
print('Hello', 'World', sep=[1])
Drag options to blanks, or click blank then click option'
A''
B'-'
C','
D' '
Attempts:
3 left
💡 Hint
Common Mistakes
Using a comma ',' as separator prints a comma between words.
Using empty quotes '' prints words without space.
2fill in blank
medium

Complete the code to print numbers on the same line separated by a dash.

Python
print(1, 2, 3, sep=[1], end='\n')
Drag options to blanks, or click blank then click option'
A'-'
B','
C''
D' '
Attempts:
3 left
💡 Hint
Common Mistakes
Using a comma ',' prints commas between numbers.
Using empty quotes '' prints numbers without any separator.
3fill in blank
hard

Fix the error in the code to print two words without a space between them.

Python
print('Hello', 'World', sep=[1])
Drag options to blanks, or click blank then click option'
A''
B','
C' '
D'_'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a space ' ' prints words with a space.
Using a comma ',' prints a comma between words.
4fill in blank
hard

Fill both blanks to print numbers 1 to 3 separated by a comma and ending with an exclamation mark.

Python
print(1, 2, 3, sep=[1], end=[2])
Drag options to blanks, or click blank then click option'
A','
B'!'
C'\n'
D' '
Attempts:
3 left
💡 Hint
Common Mistakes
Using space ' ' as separator prints spaces instead of commas.
Using '\n' as end prints a newline instead of exclamation.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase words to their lengths, only for words longer than 3 letters.

Python
result = { [1]: [2] for word in words if len(word) [3] 3 }
Drag options to blanks, or click blank then click option'
Aword.upper()
Blen(word)
C>
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'word' as key instead of uppercase.
Using '<' instead of '>' in condition.