Python Forum
Rounding without using Python embedded functions
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rounding without using Python embedded functions
#1
Good day,

So I am working on an assignment that calculates the position and velocity of an object at any given time. I get float(input) from the user on 3 data points as well as the time they wish to calculate to. My issue is we are assigned to truncate the calculation to 3 decimal places without using any built in functions of Python(i.e. round, print...). I have been looking for a couple days now and have not been able to find any examples of doing this manually.

if anyone could help I would greatly appreciate it. This is the last step I need to program and it is holding me up.

Thanks for your help.
Reply
#2
you should show what you have tried.
Quote:without using any built in functions of Python(i.e. round, print...
if you can't use print, how are you supposed to display results?
Reply
#3
Multiply, integer divide (//) by 1, true divide.

@Larz60+: If I was a prof I would say you had to name your function something particular, return the correct value, and then I would write a program to run unit tests on each program submitted.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#4
Add one half and convert to int (whoops, int is a python function).
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020