Str(pi) problem


#1

Hey, for the lessons I'm on right now, it's telling me to

Create a variable pi and set it to 3.1

4 on line 4.

Call str(pi) on line 5, after print.

This is what I did

4 pi = 3.14
5 print str(pi)

It keeps on telling me

Oops, try again. pi should equal the number 3.14--do not call str(pi) until after the print command on line 5!

Did I do something wrong here? Going by its instructions what I did should be correct!


#2

@chefyunfei The exercise is asking you to set a variable "pi" to the value 3.14, then to print the string version of pi in the next line. The instructions are pretty self explanatory. I don't think there is a problem with your code, although I can't tell for sure since I don't know if you indented anything. If you have any indents, remove them, otherwise your code should look like this:

"""Declare and assign your variable on line 4,
then call your method on line 5!"""

pi=3.14
print str(pi)

Hope that works out for you! Let me know if you still have problems. Good luck and happy coding! :slight_smile:

-- @chipjumper36731


#3

it is asking to print 3.1 not 3.14. your code will give the output as 3.14. see the floating point section again.


#4

@rabimans The instructions say:

Create a variable pi and set it to 3.14 on line 4.
Call str(pi) on line 5, after print.

I think you are mistaken with the instructions.


#5

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