Question: PYTHON CODE problem: In [: 1.) Write a function called truncate that takes a floating point number and returns that number to only 2 decimal

PYTHON CODE problem:PYTHON CODE problem: In [: 1.) Write a function called "truncate" that

In [: 1.) Write a function called "truncate" that takes a floating point number and returns that number to only 2 decimal places. For example, passing in 0.8571428571428571 should return .89 To do this, take the float number and multiply it by 100. Then cast it to an integer(int type), and then divide it by 100 2.)Modify your function above to take in a second parameter, say "n" and return "n" number of decimal points For example, passing in 0.8571428571428571 and n = 4 should return 0.8571

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!