Given a Decimal Number, extent its digits to K length.
Input : num = 76.8, K = 5
Output : 76.80000
Explanation : Length of decimal places is 5.
Input : num = 76.8, K = 6
Output : 76.800000
Explanation : Length of decimal places is 6.
Method : Using format()
This is way in which this task can be done. In this, we harness multiple format compatibilites to perform task of getting appropriate length of decimal places.
The original number is : 76.8 The resultant number : 76.8000000
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.