Intellipaat 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.

Related questions

0 votes
3 answers
0 votes
2 answers
0 votes
2 answers
asked Feb 9, 2021 in Python by Rekha (2.2k points)
0 votes
1 answer
–1 vote
3 answers

1.2k questions

2.7k answers

501 comments

693 users

Browse Categories

...