pyschool is wrong ?

Posted by geekkid on Stack Overflow See other posts from Stack Overflow or by geekkid
Published on 2012-03-31T21:00:29Z Indexed on 2012/10/27 23:01 UTC
Read the original article Hit count: 205

Filed under:
|

I'm currently learning python and trying to do exercises at pyschools (if anyone knows what it is). Anyway, i have an exercise that asks me to do the following : Write a function percent(value, total) that takes in two numbers as arguments, and returns the percentage value as an integer.

Here's my code:

def percent(value, total):
    percent = value / total * 100
    return int(percent)

It works great in my Python Idle and it gives all the correct answers. however, when i run it in the pyschools website, it says that , for example , when the function is called with parameters 46 and 90 , the function returns 0. However, in my python idle , it correctly returns 51. What might be the problem ? Thank you very much for your help!

© Stack Overflow or respective owner

Related posts about python

Related posts about homework