Practice question from Setup & Basics

Complete the code to convert a string to a decimal number:

price_str = "19.99"
price = ____(price_str)

Answer

float

Explanation

The float() function converts strings to floating-point numbers (decimals). Use int() for whole numbers and float() for numbers with decimal points.

More questions from Python Programming