Kind of non-trivial but I tried to use round(1,2)
to show 1.00
but it shows 1.0
, what can I use to show 1.00
in Python?
def series_sum(n):
# Happy Coding ^_^
sum = 0
for i in range(n):
sum += 1/(1+(3*i))
return round(sum, 2)
This is a return value for a coding challenge in codewars not a print. so it is supposed to be return and you just write the method.
Aucun commentaire:
Enregistrer un commentaire