Strings in Python
In the video, you learned of another standard Python datatype, strings. Recall that these represent textual data. To assign the string 'DataCamp'
to a variable company
, you execute:
company = 'DataCamp'
You've also learned to use the operations +
and *
with strings. Unlike with numeric types such as ints and floats, the +
operator concatenates strings together, while the *
concatenates multiple copies of a string together. In this exercise, you will use the +
and *
operations on strings to answer the question below. Execute the following code in the shell:
object1 = "data" + "analysis" + "visualization"
object2 = 1 * 3
object3 = "1" * 3
What are the values in object1
, object2
, and object3
, respectively?
This exercise is part of the course
Introduction to Functions in Python
Hands-on interactive exercise
Turn theory into action with one of our interactive exercises
