206k views
3 votes
I've attached the question. This is for python

I've attached the question. This is for python-example-1
User Mark Wang
by
5.8k points

1 Answer

7 votes

while(True):

number = int(input("Enter a positive number: "))

if(number>0):

sum=0

for i in range(number):

sum += 1/(2**(i+1))

print("The sum is:",sum)

break

else:

print("Please enter a positive number! Try again.")

I've attached the question. This is for python-example-1
User Ethem Kuloglu
by
6.3k points