A question about srt()!


#1

Please leave the following link in the post so we can find the unit module, else replace it with a link to the exact lesson:

Strings and Console Output

Hello
Could anyone help me with this question, please?

pi = 3.14
print str(pi)
print pi 

When I run it, both of the prints give the same answer, 3.14!
I mean shouldn’t the first print be “3.14” and the second one 3.14?


#2

no, if you do:

print "hello world"

you also get hello world, the quotation marks enclosing a string are not displayed when using print.


#3

Thank you for your response. I understand it.


#4

No, a str() prints only whats inside the quotes.

The quotes tell the code that it is a string.


#5

@tejasraman thank you for your response.


#6

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