Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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:
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.8571Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started