Super Strings
Briefing:
So you’ve already learnt about strings, but did you know there are some other really useful things you can do with them? Things like concatenation and using string specifiers. Take a look.
Hint:
Remember that %s
is a placeholder for Strings.
%d
is a placeholder for numbers (think of d for digit).
%f
is a placeholder for floats (remember these are numbers with a decimal point)
Make sure you create the requested variables, and use them in a format string to print the specified sentence.
Code Solution:
The following code is the solution to this challenge. Please note that there may be alternative ways to complete this challenge.
# CHALLENGE 1: Save the integer 5 in the variable ch1_1, and
# the string "robots" in the variable ch1_2
# Use a format string to print the following sentence:
# There are 5 robots in the room
ch1_1 = 5
ch1_2 = "robots"
print("There are %d %s in the room" % (ch1_1, ch1_2))