How to calculate this mathematical expression in python? [closed] - python

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I wanted to calculate this mathematical expression in python3:
Xi = (70 + 1344736401384689745317259585614247891453883777111/315)% 115792089210356248762697446949407573529996955224135760342422259061068512044369
But I'm getting this wrong result: 4.2690044488402846e+45 . Is there something wrong in the expression? how can I fix it to give me the right result?

I think you might be confused because it is showing scientific notation? '{}'.format() should help in that case.
Xi = (70 + 1344736401384689745317259585614247891453883777111/315)% 115792089210356248762697446949407573529996955224135760342422259061068512044369
print('{0:f}'.format(Xi))

Related

How can I use several different types inputs together? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 days ago.
Improve this question
multi inputs in python
write a program to take X and Y as input and out put the string x ,repeated y times.
sample input
hi
3
sample output
hi hi hi

Converting H/T to 0/1 binary array [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed last year.
Improve this question
I’ve loaded a sample using the code:
Data = np.load(sample_1.npy)
I need to convert the data points from H/T (coin tosses) to 0/1 (binary array). Not sure what code would work for this? I’ve tried googling answers and they haven’t worked.
If it's an array with "H" and "T" as values, you could try that:
Data = np.array([0 if x == "H" else 1 for x in Data])

Weird interaction with using variables as arguments in a method call [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
Im wondering if somebody could please explain to me why does the left side not work but right side does? Why does assigning the radiuses to variables first produce the wrong calculation in the end?
Look at line 9 of each of the two codes you posted. On the left side, you are doing 26 / 2, whereas on the right side you do 36 / 2 …

how to cast certain key values to floats using python [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
Given this dictionary:
my_dict={'animal':['Dog','Cat'],'age':[4,5],'bark':[True,False],'badge_num':['234','896']}
what code will cast 'age' to float?
you could use map combined with float like the following:
my_dict['age']=list(map(float, my_dict['age']))

How to convert list to integer [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
When I run
print(c)
I get the output
[45]
How do I remove the [ ] and get output like this as an integer?
45
Because I want to print this but It won't run.
print(b[c:c+50])
Take the first element of that array.
print(c[0])

Categories

Resources