Which Python built-in function would you use to convert a string into a number?
list()
int()
str()
float()
int()
orfloat()
To convert a string into a number in Python, you can use the built-in functions int()
or float()
, depending on whether you want an integer or a floating-point number. The int()
function is used to convert a string into an integer, while float()
is used to convert a string into a float number. str()
converts other data types to string and list()
converts other types to list.
Loading...
Related Quiz
- The ____ keyword is used to create a block of code that can handle exceptions in Python.
- The concept where the inner function captures and remembers the enclosing function's local state is called _______.
- A ____ is a type of binary tree where the tree automatically balances itself as items are inserted or removed.
- How can you create an else block that executes after a for loop, but only if the loop completed normally (i.e., did not encounter a break statement)?
- Which function in Python is used to read file contents as a string?