Str()


#1

the str () method turns non-strings into strings. So on the visualizer, 3.14 had to turn to “3.14” but instead i get 3.14.



pi=3.14
print str(pi)
3.14


#2

well, if we do:

print "hello world"

you also get:

hello world

as output, python doesn’t print quotation marks when printing a string

a way to confirm pi is a string we can use type(), which gives us the type (surprise xD):

print type(str(pi))

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.