0

So, in my beginner python class, we were asked to perform some basic arithmetic on numbers typed by the user, basic stuff. It was supposed to return a number with 2 decimal places, but I can only get it to extend to one. If the decimal terminates at the first decimal, is there a way to add another place? If the decimal terminates later, or is infinite, is there a way to display the second number as well?

    print "Please enter the month of your birthday as a number.";
    print "\t Jan = 1";
    print "\t Feb = 2";
    print "\t Apr = 3"
    print "etc, etc, etc."
    num = input("\n");
    day = input("What date were you born on?\n");
    new = (((((((((((num * 7.0) - 1.0) * 13.0) + day) + 3.0) * 11.0) - num) - day) / 10.0) + 11.00) / 100.0);
    print "You were born in the", new, "month.";
  • 2
    Possible duplicate of [Limiting floats to two decimal points](https://stackoverflow.com/questions/455612/limiting-floats-to-two-decimal-points) – bphi Sep 08 '17 at 15:05

1 Answers1

0

Just had to experiment for a little bit, and my solution is kind of cheating.

    new = str(new) + "0";

This changes the "new" into a string, and adds an extra 0 to the float.