for _ in range(3): sec=sec+1.3 round(sec) print(sec)   I am working on a GUI/ML project and i ran the above simple snippet.I have to display the number in the GUI(pyqt5) but the output is all messed up.Here is the output that i got.(sec=0 at the start obviously)   1.3 2.6 3.9000000000000004   Questions:-   Why is the output 3.9000000000000004??Why the anomaly?? I have tried multiple ways to round up the number like ....but nothing works!! How can i round this upto 1/2 decimal places???
31758
The documentation for the  function states that you pass it a number, and the positions past the decimal to round. Thus it should do this:  n = 5.59 round(n, 1) # 5.6   But, in actuality, good old floating point weirdness creeps in and you get:  5.5999999999999996   For the purposes of UI, I need to display 5.6. I poked around the Internet and found some  that this is dependent on my implementation of Python. Unfortunately, this occurs on both my Windows dev machine and each Linux server I've tried. .  Short of creating my own round library, is there any way around this?
61612
I'm looking for a  way to convert numbers to string format, dropping any redundant '.0'   The input data is a mix of floats and strings. Desired output:  0   --> '0'  0.0 --> '0'  0.1 --> '0.1'  1.0 --> '1'  I've come up with the following generator expression, but I wonder if there's a faster way:  (str(i).rstrip('.0') if i else '0' for i in lst)   The truth check is there to prevent 0 from becoming an empty string.  EDIT: The more or less acceptable solution I have for now is this:  ('%d'%i if i == int(i) else '%s'%i for i in lst)   It just seems strange that there is no elegant way to handle this (fairly straightforward) case in python.
568
I am looking for a Calculator which can do calculations in the terminal itself without any other extra prefixes and suffixes.  For example: If I typed something like 10000-9000 in the terminal, the answer should come out as 1000.  Once again I am saying, I just need a quick calculator in terminal, without any characters added. I know if I switch to Python, it can do that but I don't want it in such a way.
113604
I was messing around with my TI-84 Plus Silver Edition calculator and discovered that it will actually give me values when taking the factorial of any number $n/2$ where $n$ is any integer greater than $-2$. Why does this happen? I thought factorials were only defined for positive integers and $0$, so what is my calculator doing to get the answer $3.32335097$ when I enter $2.5!$? Is there actually a definition of $2.5!$ or is my calculator just being weird? How is the factorial function implemented?  I understand the binary implications of $2.5$, so that could possibly have something to do with it. I get a domain error when trying to take the factorial of $-1, 2.3, e$, and any number that is not of the form $n/2$ where $n$ is any integer greater than $-2$.
12929
Could someone please tell me what I'm doing wrong with this code? It is just printing 'count' anyway.  I just want a very simple prime generator (nothing fancy).   import math  def main():     count = 3     one = 1     while one == 1:         for x in range(2, int(math.sqrt(count) + 1)):             if count % x == 0:                  continue             if count % x != 0:                 print count          count += 1
89964
I'm trying to find outliers using 1.5 x interquartile range but I'm getting a negative value for the lower bound. I found Q3 and Q1 which are 13.30 &amp; 3.00 respectively but for the lower bound i get -12.45 which seem odd. Is there something I'm doing wrong?   There are 43 numbers in this chart so I just get (75/100)*43 to find Q3 and (25/100)*43 to find Q1
67589
Suppose I have 30 numbers that vary between 0 and 1.0 and which sum to 1.0.  The mean is obviously 0.033.  A client wants these scaled to lie between 0 and 1.0 but to have a mean of 0.5.  By the way, I'll probably have to do this for any set of numbers (positive, negative, outside the range 0 - 1) so that they lie in the range 0 - 1 and have a mean 0.5.  Any suggestions?
92773
How many Decimal Places are Needed For Accuracy to a Given Number of Significant Figures?  For example: $1234/3.141 = 392.8$, but $1234/3.14159$ changes the result to $392.7$, so how do I am using enough digits of $\pi$ for my result to be accurate to a given number of significant figures?
41750
If I type in a 16 digit number (format: number, no decimals) it changes the number on me. Example: 1234567812345678 changes the view to 1234567812345670.    If I type it in as a general format it changes the numbers above so it displays 1.23457E+15 but if you click on the cell, the display shows the last digit as a 0 instead of an 8 once again.   I opened the file on a different computer and same issue now with it.  I have changed the auto correction and auto formatting all to no avail.  Help!
90637
Excel converting value 0503E000 to 5.03E+02 in any cell automatically in CSV I tried to convert it to text number and general but after i save it and reopen it again it goes back to 5.03E+02  How do I stop this from happening?
60608
I have the value 25.00 in a float, but when I print it on screen it is 25.0000000. How can I display the value with only two decimal places?
94875
I want to print list of numbers from 1 to 100 and I use a for loop like the following:  number=100 for num in {1..$number} do   echo $num done   When I execute the command it only prints {1..100} and not the list of number from 1 to 100.
73750
I need to find out how to format numbers as strings. My code is here:  return str(hours)+":"+str(minutes)+":"+str(seconds)+" "+ampm   Hours and minutes are integers, and seconds is a float.  the str() function will convert all of these numbers to the tenths (0.1) place.  So instead of my string outputting "5:30:59.07 pm", it would display something like "5.0:30.0:59.1 pm".  Bottom line, what library / function do I need to do this for me?
95140
I have the number 0.101 in binary. I want to round it to 2 places after the radix point using the algorithm rounding to the nearest. Here is how I do it.  If I want to have two places, then I will have one of the two possible resulting numbers: 0.10 or 0.11. Let's see how by how much each is different from the original:   1) 0.101 - 0.10 = 0.11  2) 0.101 - 0.11 = 0.10  The second one gives us less difference then the first, so using the algorithm rounding to the nearest, 0.101 should be rounded to 0.11. Is this how the algorithm works?
59699
Here is the code.  \documentclass{article} \begin{document} \directlua{tex.sprint(tostring(math.sin(math.pi)))} \\ \directlua{tex.sprint(tostring(math.tan(math.pi/2)))} \end{document}   I am expecting the answers as 0 and error . The code above gives some very small and big number. Can I get the expected answers by some modifications in code?
26607
Is the concept of even/odd numbers applicable to decimal numbers? For e.g. - 4.222 is a even number?
17181
echo "scale=3;1/8" | bc   shows .125 on the screen. How to show 0.125 if the output result is less than one?