I can't do the factorial calculation and addition function [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
The problem he faced is briefly. I need to write a function that calculates the factorial. This function must calculate the factorial of the numbers I send (of more than one number). After calculating the factorial of the numbers I sent him, he should add them all and send them back to me. I do both separately, but I cannot do it together. I leave the link of the codes.
https://pastebin.ubuntu.com/p/dRJnMT7fkt/
enter image description here

Maybe you can use this:
def Faktoriyel(a):
sonuc=0
for f in a:
sonucumuz=1
for i in range(1,f+1):
sonucumuz *= i
sonuc += sonucumuz
return sonuc
Here you go as you requested one function.
If it helps you please upvote and accept the answer.

Related

Ignoring the zero after the coma when rounding in 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
This is my first week at college (Cyber security), and I don't have any coding background.
For a python assignment, I have to round the amounts to two decimal places, but if the last decimal is a zero, it should not show in the output. What is the appropriate rounding code I should use?
This is my code:
if (valuta == 1):
print("Voor", bedrag, "US Dollar krijgt u ", round(USDollar,2),"Euro, De transactiekosten bedragen", round(DollarTransactiekosten,2), "Euro. U ontvangt",round(AfgerondDollar,2), "Euro" )
Edit: Thanks for all the answers and help guys
It looks like you're new to programming, so here's a few pointers. I'm not going to write all the code you need for an answer here because then how will you learn? Instead, here's the thought process behind coming up with a way to code a solution to your problem.
We have a number x.
We want to round it to two decimal places.. Think about what format specifier you'll use. Let's save this result in str_x.
If the last character in this string is a zero, we want to get rid of it.
What we have now is what we required.

Finding the limit of a sequence in python, jupyter notebook [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
I’ve got a sequence a(n)=(5-77sin(n)+8n^2)/(1-4n^2) and I’m trying to find a candidate for the limit of this sequence. How do I do this? I’ve tried using a code below but that didn’t work so any ideas?enter image description here
As discussed here, for sympy you need to use ** for raising to a power and not ^.
This will work:
from sympy import limit, sin, Symbol, oo
from sympy.abc import x ,n
r = limit((5-77*sin(n)+8*n**2)/(1-4*n**2),n , oo)
r
Adaptation of OP code based on:
https://docs.sympy.org/latest/modules/abc.html
https://docs.sympy.org/latest/modules/series/series.html

Why am i getting this error? need help please [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
I am getting this error.. code not submitting
need help thanks in advance
I believe your error is in finding the midpoint.
In python, if we use len(lst)/2 it will return float value.
The Index of list cannot be a floating point value.
Change your line to:
midpoint = len(lst)//2
This will return an Integer value as output.

pandas DataFrame cut [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
i want to cut all the columns of Data Frame. When I print the result it show good result, but when I want to assign those values in new data frame it returns NaNs.example of code
You need to paste your code here for understanding proper solution of problem.
you can try to add one line of code:
slc=slc.reset_index(drop=True)

Random order generator using filtering and recursion [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 years ago.
Improve this question
I am trying to create a random order generator. I have a list of ten names and want to write a program that returns the same list in a random order.
Here is my code which I'm told has invalid syntax in line 11
.
I am trying to complete the problem using filtering and recursion to further my understanding of these tools.
random.shuffle() is what you are looking for.

Categories