Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (55.6k points)

A.  int(x[, base] )

B. long(x[, base] )

C. float(x)

D. str(x)

1 Answer

0 votes
by (119k points)
edited by

The answer is option C (float(x)). float(x) method converts x to a floating-point number.

#Convert string to float

x = '1234'

x1 = float(x)

type(x1) #check the datatype after conversion

Output:

Float

You can check out this Python Functions to learn more about data type conversions with examples.

Also, watch this video on Python Functions:

If you are interested to learn Python from Industry experts, you can sign up for this Python Certification Course by Intellipaat.

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

30.4k questions

32.5k answers

500 comments

108k users

Browse Categories

...