Concatenate string and float python
Our geometry teacher gave us an assignment asking us to create an example of when toy use geometry in real life, so I thought it would be cool to make a program that calculates how many gallons of water will be needed to fill a pool of a certain shape, and with certain dimensions. Show
Here is the program so far:
i keep getting this error though:
what do i do?
nircraft 7,6665 gold badges29 silver badges45 bronze badges asked Jun 5, 2013 at 19:31
0 All floats or non string data types must be casted to strings before concatenation This should work correctly: (notice the
straight from the interpreter:
answered Jun 28, 2013 at 13:23
Kalyan02Kalyan02 1,38610 silver badges16 bronze badges 1 There is one more solution, You can use string formatting (similar to c language I guess) This way you can control the precision as well.
without precision
With precision 8.2
answered May 17, 2019 at 19:00
Gaurang ShahGaurang Shah 10.6k5 gold badges65 silver badges119 bronze badges With Python3.6+, you can use f-strings to format print statements.
answered Oct 3, 2019 at 0:50
TyberiusTyberius 6022 gold badges10 silver badges19 bronze badges Not the answer you're looking for? Browse other questions tagged python string concatenation or ask your own question.This article describes how to concatenate strings in Python.
Concatenate multiple strings: +, += operator
|