13. Why use str(3.14) rather than just putting "3.14?"


#1


I'm not exactly stuck. More of a mental block. And maybe it's just because they're trying to teach the strings and the ways to manipulate them.

But why would I use str(3.14) rather than just putting quotes around it?

Both output the same thing (and actually pass the lesson), the main difference is one keeps it a variable and just uses it as a string, the other turns it into a string.

Perhaps I answered my question as I typed it. This would be useful later on when I might want to print out something like:

spam = 3.14

print "The value of pi is around" + str(spam)

Is that the main benefit of using str over " "? It's more versitile in the above example?

https://www.codecademy.com/courses/python-beginner-sRXwR/3/2?curriculum_id=4f89dab3d788890003000096


python
Replace this line with your code.


#2

Hi like you said..

Perhaps I answered my question as I typed it. This would be useful later on when I might want to print out something like:
spam = 3.14
print "The value of pi is around" + str(spam)

yes , you right