For converting a string to float you can use float(). Eg.float('1.2123') You can not convert '*' into float because its an operator that's why error is coming.

#observe the code
volume = float(input("Enter volume of sphere in mm^3: "))

input() = Takes input from user and stores it in string

float() = It is used to convert strings to float

Your code is volume = float(input("Enter volume of sphere in mm^3: "))

1st input() takes input from user in string then float() converts it into float.

But a = 1.4*1.0e6 there is no input() function involved thats why it's a float.

You can simply achieve your work by

volume = eval(input("Enter volume of sphere in mm^3: "))

OR

volume = input("Enter volume of sphere in mm^3: ").split("*")
volume = float(volume[0])*float(volume[1])

split(separator)- It splits a string into an array of sub-strings, by a separator string provided by user

You can read about eval from here:- Read abut eval() from here

Answer from Abhay Kumar on Stack Overflow
๐ŸŒ
OpenReplay
openreplay.com โ€บ tools โ€บ rgba-to-hex
RGBA to HEX Converter
To convert from 8-digit hex to RGBA, split the hex into RGB components and convert the last two digits to a decimal between 0 and 1 for the alpha value.
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ how to convert string to float in python?
Convert String to Float in Python - Scaler Topics
May 5, 2022 - For converting the list of strings ... have to iterate the string list and take the values one by one and then convert the string values to the floating values and then append all the float values to the floating value list...
Discussions

How to convert string to float in Python? Why is it a float when directly assigned but a string when a user inputs it? - Stack Overflow
My program prompts the user to input the volume of a sphere. This is one of the example input I have to try: 1.4*1.0e6 This is what I have as the prompt right now: volume = float(input("Enter More on stackoverflow.com
๐ŸŒ stackoverflow.com
Python string to float conversion
I don't know what you mean: >>> a = '1721244344.700249000' >>> float(a) 1721244344.700249 These are all the decimal places. Trailing zeros will always be omitted as they are irrelevant. If you want to show them, do so when you output the value: >>> print(a.format("{:.9}")) 1721244344.700249000 More on reddit.com
๐ŸŒ r/learnpython
18
5
July 29, 2024
Is it legal/valid to use float() to convert a string containing integer to float?
Hi, Iโ€™m wondering if float(โ€˜10โ€™) (or any integer string) can be safely converted using float() to float number. Documentation of float() states that: the input must conform to the following grammar after leading and trailing whitespace characters are removed: sign ::= "+" | "-" infinity ... More on discuss.python.org
๐ŸŒ discuss.python.org
2
December 22, 2022
convert string to float?
if you really want to convert "1" of type str to 1 of type int then you can do something like that: ord("1")-48 this returns Unicode value of the digit, which is 48 for "0", 49 for "1", 50 for "2" etc. from that, it should be easy to create a floating point number in the for loop More on reddit.com
๐ŸŒ r/learnpython
16
2
September 22, 2022
๐ŸŒ
Cherry Servers
cherryservers.com โ€บ home โ€บ blog โ€บ python โ€บ how to convert string to float in python (6 different ways)
How to Convert String to Float in Python (6 Different Ways) | Cherry Servers
July 25, 2024 - ... Using the float() function is the most common way to convert string to float in Python. Whatโ€™s more, it is a built-in function which means it comes with standard Python installation.
๐ŸŒ
Hostman
hostman.com โ€บ tutorials โ€บ how to convert string to float in python
How to Convert String to Float in Python
March 31, 2025 - In this article weโ€™ve covered a common example of type casting which is converting a string to a float using the float() function. We also used the try/except block to handle conversion errors when the input string format is not valid.
Price ย  $
Call ย  +1 844 286 2130
Address ย  1999 Harrison St 1800 9079, 94612, Oakland
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ python string to float conversion
r/learnpython on Reddit: Python string to float conversion
July 29, 2024 -

Hi all, I have a string a = '1721244344.700249000', I want to convert it to a floating value.

Float() is returning only 2 places after decimal point. Like 1721244344.7

Is there a way I can convert the entire string to a floating point value and get all the decimal (upto 9 places after decimal point)?

I have to use python v2.7 for this.

Edit: I do not have problem in printing the all 9 decimal places but I need the floating value so that I can subtract another value so that I get the difference with accuracy upto 9 th decimal point.

๐ŸŒ
DigitalOcean
digitalocean.com โ€บ community โ€บ tutorials โ€บ python-convert-string-to-float
How to Convert String to Float in Python: Complete Guide with Examples | DigitalOcean
July 10, 2025 - Learn how to convert strings to floats in Python using float(). Includes syntax, examples, error handling tips, and real-world use cases for data parsing.
Find elsewhere
๐ŸŒ
Python Engineer
python-engineer.com โ€บ posts โ€บ string-to-float
How to convert a string to float/integer and vice versa in Python - Python Engineer
February 9, 2022 - The result will include the whole number part of the float, as the decimal part is discarded during float to int conversion. ... ```python number_as_string = "3.14159" number_as_float = float(number_as_string) number_as_integer = int(number_as_float) print(number_as_integer) ... A ValueError is also thrown in any other case where the string cannot be converted to a number.
๐ŸŒ
Centron
centron.de โ€บ startseite โ€บ how to convert a string to a float in python
How to Convert a String to a Float in Python
February 7, 2025 - This tutorial was tested with Python 3.9.6. We can convert a string to float in Python using the float() function. This is a built-in function used to convert an object to a floating point number.
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_casting.asp
Python Casting
Python is an object-orientated language, and as such it uses classes to define data types, including its primitive types. Casting in python is therefore done using constructor functions: int() - constructs an integer number from an integer literal, a float literal (by removing all decimals), or a string literal (providing the string represents a whole number)
๐ŸŒ
ServiceNow
servicenow.com โ€บ docs โ€บ r โ€บ washingtondc โ€บ api-reference โ€บ server-api-reference โ€บ DynamicTranslation.html
Docs | ServiceNow
Loading application ยท Your web browser must have JavaScript enabled in order for this application to display correctly
๐ŸŒ
Note.nkmk.me
note.nkmk.me โ€บ home โ€บ python
Convert a String to a Number (int, float) in Python | note.nkmk.me
April 29, 2025 - In Python, you can convert a string (str) to a number using int() for an integer or float() for a floating-point number. Convert a string to int: int() Convert a string to float: float() Convert a bin ...
๐ŸŒ
Python
docs.python.org โ€บ 3 โ€บ library โ€บ json.html
json โ€” JSON encoder and decoder
2 weeks ago - If None (the default), it is equivalent to int(num_str). This can be used to parse JSON integers into custom datatypes, for example float. parse_constant (callable | None) โ€“ If set, a function that is called with one of the following strings: '-Infinity', 'Infinity', or 'NaN'.
๐ŸŒ
Python documentation
docs.python.org โ€บ 3 โ€บ library โ€บ stdtypes.html
Built-in Types โ€” Python 3.14.3 documentation
2 weeks ago - For example, the hexadecimal string 0x3.a7p10 represents the floating-point number (3 + 10./16 + 7./16**2) * 2.0**10, or 3740.0: ... Applying the reverse conversion to 3740.0 gives a different hexadecimal string representing the same number: ... The complex type implements the numbers.Complex abstract base class. complex also has the following additional methods. ... Class method to convert a number to a complex number.
๐ŸŒ
Godot Engine
docs.godotengine.org โ€บ en โ€บ stable โ€บ tutorials โ€บ scripting โ€บ gdscript โ€บ gdscript_basics.html
GDScript reference โ€” Godot Engine (stable) documentation in English
GDScript is a high-level, object-oriented, imperative, and gradually typed programming language built for Godot. It uses an indentation-based syntax similar to languages like Python. Its goal is to...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ convert-string-to-float-in-python
Convert String to Float in Python - GeeksforGeeks
July 15, 2025 - It converts a string into a Decimal object, effectively avoiding common floating-point rounding errors. ... eval() function reads and runs a string as a Python expression. It can turn a numeric string like "33.28" into a float. However, it's risky to use with untrusted input because it can run harmful code.
๐ŸŒ
Python.org
discuss.python.org โ€บ python help
Is it legal/valid to use float() to convert a string containing integer to float? - Python Help - Discussions on Python.org
December 22, 2022 - Hi, Iโ€™m wondering if float(โ€˜10โ€™) (or any integer string) can be safely converted using float() to float number. Documentation of float() states that: the input must conform to the following grammar after leading and trailing whitespace characters are removed: sign ::= "+" | "-" infinity ::= "Infinity" | "inf" nan ::= "nan" numeric_value ::= floatnumber | infinity | nan numeric_string ::= [sign] numeric_value where floatnumber, described in Floating point li...