Skip to main content
Filter by
Sorted by
Tagged with
1 vote
0 answers
100 views

I'm wondering if this is a simply mypy config issue, but I'm getting the following error when running mypy against some libraries, some of which use fractions._RATIONAL_FORMAT module attribute, which ...
srm's user avatar
  • 595
0 votes
2 answers
73 views

I am using the class constructor Fraction to create fractions. What is the difference between using the Fraction class constructor and from_float method when creating fractions from floating-point ...
winter's user avatar
  • 53
-2 votes
1 answer
346 views

Are there differences? if so, what are they? What are the advantages and disadvantages? If there are other implementations of rational numbers in python, feel free to include those in the comparison.
CatCallofCthulhu's user avatar
2 votes
1 answer
1k views

I'm trying to solve a problem about Bernoulli numbers using Python. The aim is to output the numerator and the denominator of the $n$-th Bernoulli number. I use the conventions and the generic formula ...
Barbara Gendron's user avatar
3 votes
1 answer
309 views

I'm trying to convert very large integers to decimals, then convert those decimals to Fractions, and then convert the Fraction back to a decimal. I'm using the fractions and decimal packages to try ...
Einsneins's user avatar
-1 votes
2 answers
100 views

I want to do a story problem on the following math. A merchant sells an item at a price $210.00 and profit 5% of the price buy. Determine the purchase price the item. The answer is like the following ....
Fahrizal's user avatar
-3 votes
1 answer
35 views

For Example this is my list li = [4.0, 5.15445454, 1.1] and I want to this newli = [4.00000, 5.15445, 1.10000]
Partho Debnath's user avatar
0 votes
0 answers
363 views

Just for a simple example, if I have an array like this: data=np.array([[1/3,2/7],[3/5,5/6]]) Is there any quick way to convert it to the following without defining a function? If we can't do it for ...
adfdsfsdf's user avatar
4 votes
1 answer
228 views

from fractions import Fraction class F1(Fraction): def __init__(self, *args, **kwargs): Fraction.__init__(*args, **kwargs) class F2(Fraction): def __init__(self, *args, **kwargs): ...
Confused Learner's user avatar
0 votes
1 answer
486 views

from fraction.py import * f1 = Fraction(3,4) f2 = Fraction(2,3) f3 = f1 * f2 print(f3) File "python.4", line 1, in <module> from fraction import * File "/home/PYTHON/...
Victoria's user avatar
-1 votes
2 answers
248 views

How do I write a python def function that can take the cube roots of fractions and return the answer as a fraction as a coefficient with a cube root in the numerator only? I am new to coding, so I ...
Patman1O1's user avatar
1 vote
1 answer
102 views

lst = [1, 2, 3] match lst: case list((1, 2, 3)): print(2) gives 2 as output, but, from fractions import Fraction frctn = Fraction(1, 2) match frctn: case Fraction(1, 2): print(1) gives,...
apostofes's user avatar
  • 3,833
0 votes
0 answers
332 views

>>> from fractions import Fraction D:\_w\1\s\Modules\_decimal\libmpdec\context.c:57: warning: mpd_setminalloc: ignoring request to set MPD_MINALLOC a second time Traceback (most recent call ...
Lyman's user avatar
  • 11
0 votes
2 answers
2k views

So im trying to write a code that will solve general solutions in calculus and one of my values is a fraction with f1 = fractions.Fraction(2.0, period) but if I use 12.5 as the period it comes back ...
Killogee's user avatar
1 vote
0 answers
21 views

I was trying to teach a Python lesson to my son, and we are having a little problem... Can someone explain to me how this is happening? PS >>>> python3 Python 3.9.12 (tags/v3.9.12:b28265d, ...
poteus's user avatar
  • 11
0 votes
1 answer
402 views

Here is an example: x = frac(1,3) x Out[138]: Fraction(1, 3) y = frac(5/39) y Out[140]: Fraction(288692283805801, 2251799813685248) print(x+y) 3117876665102651/6755399441055744 x+y Out[142]: Fraction(...
Francis111333's user avatar
1 vote
1 answer
582 views

So I have a simple example: import fractions f = fractions.Fraction(6, 12) and I don't want f to become 1/2. I want it to remain 6/12. Is there a way to do this?
Oleksandr Novik's user avatar
0 votes
1 answer
573 views

I was trying to solve an equation for the catenary and wanted to use the Newton-Raphson method. from math import sinh, cosh y = 0.4 #Has taken to initiate the iteration. k = 3/2 for _ ...
user avatar
-1 votes
1 answer
924 views

the first table to be converted to minute: Time_sec >>> Time_Min) 362.7313 00:06:02,7 490.669 00:08:10,7 824.5673 00:13:44,6 951.829 00:15:51,8 13.0447 00:00:13,0 13.0678 ...
e33's user avatar
  • 15
0 votes
0 answers
86 views

Have got dataframe at store-product level as shown in sample below: Store Product Space Min Max Total_table Carton_Size 11 Apple 0.25 0.0625 0.75 2 ...
user12345's user avatar
  • 509
0 votes
0 answers
52 views

x = np.linspace(-1,1,10) for k in x: print (Fraction(k).denominator) I 'm trying to get the denominator for this values in this range, but I get this instead 1 9007199254740992 4503599627370496 ...
Quinexus's user avatar
1 vote
3 answers
831 views

I want to take the reciprocal of Fraction in python, and do so in-place. The Fraction class does not provide a method for doing so (in my knowledge). I tried to just swap numerator and denominator: f =...
dranjohn's user avatar
  • 693
8 votes
2 answers
4k views

I have a list of fractions that I need to transform. from fractions import Fraction fractions_list=[Fraction(3,14),Fraction(1,7),Fraction(9,14)] The output should be a list with the numerators for ...
Maximilian Jesch's user avatar