1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Eva8 [605]
4 years ago
13

Develop a Python module that will prompt the user for a target sum that is greater than 0 and less than 1 for the following Geom

etric series: Geometric Series Equation The program should first make sure the target sum is within the range specified above. If not, continue to prompt the user for a target sum until it is in the specified range. The program should then compute the Geometric Series until it is greater than or equal to the target sum. The program should output the final sum as well as the number of terms required in the sequence to reach that final sum.
Computers and Technology
1 answer:
marusya05 [52]4 years ago
8 0

Answer:

see explaination

Explanation:

target_sum=float(input("Enter a target sum > 0 and <1 : ")) #asking user to enter the sum

while (target_sum<0 or target_sum>1): #if target sum not in range print the message

print("The target sum is not between 0 and 1")

target_sum=float(input("Please Enter a target sum > 0 and <1 : "))

computed_sum=0.00 #declare computed_sum

term_count=0 #declare term count and initalize to 0

r=1 #variable used to create the difference value

while computed_sum<target_sum: #iterate loop till computed sum is less than target sum

computed_sum=computed_sum+(1/(2**r)) #add previous computed sum with current term (1/2,1/4,1/8 etc)

term_count+=1 #increment term count

r+=1 #increment r value

print("Final Sum = " ,computed_sum) #finally print term count and final sum

print("Number of Terms= " ,term_count)

You might be interested in
write a pay-raise program that requests a person's first name, last name, and current annual salary, and then displays the perso
belka [17]

Without more information for what the programming language is I cannot give a full answer, so I listed a potential method for calculating salary.

To calculate the salary (Java):

public static double getSalary(double salary) {

   if (salary < 40000) {

        return salary + (salary * 0.05);

   }

   return 2000 + ((0.02 * salary) + salary);

}

To calculate the salary (VB .Net):

Function getSalary(ByVal salary As Double) As Double

   If salary < 40000 Then

       salary = salary + (salary * 0.05)

   Else

       salary = 2000 + ((0.02 * salary) + salary)

   End If

   Return salary

End Function

7 0
3 years ago
Who was the first person to develop http the language in which servers and browsers communicate
Rudiy27
The answer would be Tim Berners- lee
6 0
3 years ago
What steps should you take if your harassed online​
AURORKA [14]
Tell an adult and report the person harassing you
8 0
3 years ago
Read 2 more answers
Which fonts do not have a practical use in writing
kondaur [170]
To be honest with you, I don’t know but you can always look up on google “which fonts do not have a practical use in writing” and then there are links you can look up for the answer . Sorry but I don’t know which link is the best answer for your question ;) have a great day bro
8 0
3 years ago
Which of the following is the BEST example of the principle of least privilege? Correct Answer: Wanda has been given access to t
pishuonlain [190]

Answer: Wanda has been given access to the files that she needs for her job.

Explanation:

The principle of least privilege is when a user is only given the minimum level of permissions that he or she needs to perform a particular job function. This helps in reducing the risk of attackers having access to data.

The best example of the principle of least privilege is Wanda has been given access to the files that she needs for her job. Given access to all of the file servers or access to all of the files on one server is incorrect.

7 0
3 years ago
Other questions:
  • A(n) ______ chart is drawn on the same worksheet as the data.
    10·1 answer
  • 30 POINTS!!
    15·2 answers
  • Create a DisplayBox application that prompts the user for a height and width and then displays a box of that size. The DisplayBo
    8·1 answer
  • Which of these items will least likely increase pressure in the evaporative emission control system?
    9·1 answer
  • A conditional expression is normally expressed within the ___?___ or HAVING clauses of a SQL statement. (SELECT, ORDER BY, PARSE
    7·1 answer
  • _____ are networks that learn and are capable of performing tasks that are difficult with conventional computers.
    11·1 answer
  • The advantage of returning a structure type from a function when compared to returning a fundamental type is that
    5·1 answer
  • Who like the videos where is clown is from :)
    6·1 answer
  • Portable Document Format is a proprietary document file type created by Adobe Systems that is compatible with most computer syst
    7·1 answer
  • May someone help me with the this question pls , The governor of a state wants to inform the people about a change in the tax po
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!