Sometimes, while working with tuple, we can have a problem in which, we need to convert a tuple to floating-point number in which first element represents integer part and next element represents a decimal part. Let’s discuss certain way in which this can be achieved.
Method : Using
join() + float() + str() + generator expression
The combination of above functionalities can solve this problem. In this, we 1st convert the tuple elements into a string, then join them and convert them to desired integer.
The original tuple : (4, 56) The float after conversion from tuple is : 4.56
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course