You are viewing a single comment's thread. Return to all comments →
Because, in Python, if you divide two ints, you would get the result of the integer division, in this case 0. But if the N is stored as a float, you are already forcing the floating point division here.
To my knowledge, that is only the case for Python 2. Python 3 returns the fractional part as well even if you divide two ints. :)
yeah I think that's right
Right, in python3 if you dont want the fraction just use floor division a//x.
In C# as well. Took me "forever" to find out.
int n = Convert.ToInt32(Console.ReadLine());
string arr_temp = Console.ReadLine().Split(' ');
int array_temp= Array.ConvertAll(arr_temp,Int32.Parse);
int PositiveNumbers= array_temp.Where(x=>x>0).ToList().Count;
int zeroNumbers=array_temp.Length-(PositiveNumbers + NegativeNubers);
decimal Pos=(decimal)PositiveNumbers / n;
decimal Neg=(decimal)NegativeNubers / n;
decimal Zer=(decimal)zeroNumbers / n;
you could also import division from future which fixes the integer and float division as in Python 3.