Part 1 - Using your Geometric Progression, write a script that verifies a Geometric progression with -1

1 answer below »
Python coding question


Part 1 - Using your Geometric Progression, write a script that verifies a Geometric progression with -1< r="">< 1 and != 0 sum approaches ( starting_value / ( 1 - r ) ), allow the user to enter an r value ( make sure to convert to a float ) and run until you are within .00001 of the calculated sum, outputting the current sum in each iteration. starting_value * r^nth-1 is each term 1st term is starting_value * r^0 2nd term is starting_value * r^1 3rd term is starting_value * r^2 part 2 - use the fibonacci progression to test the theory of number distribution - https://en.wikipedia.org/wiki/benford%27s_law (links to an external site.) grab the first 500 values of fibonacci and count the instances of each first digit ( the easy way is to convert it to a string and grab the first character https://en.wikipedia.org/wiki/benford%27s_law 1="" and="" !="0" sum="" approaches="" (="" starting_value="" (="" 1="" -="" r="" )="" ),="" allow="" the="" user="" to="" enter="" an="" r="" value="" (="" make="" sure="" to="" convert="" to="" a="" float="" )="" and="" run="" until="" you="" are="" within="" .00001="" of="" the="" calculated="" sum,="" outputting="" the="" current="" sum="" in="" each="" iteration.="" starting_value="" *="" r^nth-1="" is="" each="" term="" 1st="" term="" is="" starting_value="" *="" r^0="" 2nd="" term="" is="" starting_value="" *="" r^1="" 3rd="" term="" is="" starting_value="" *="" r^2="" part="" 2="" -="" use="" the="" fibonacci="" progression="" to="" test="" the="" theory="" of="" number="" distribution="" -="" https://en.wikipedia.org/wiki/benford%27s_law="" (links="" to="" an="" external="" site.)="" grab="" the="" first="" 500="" values="" of="" fibonacci="" and="" count="" the="" instances="" of="" each="" first="" digit="" (="" the="" easy="" way="" is="" to="" convert="" it="" to="" a="" string="" and="" grab="" the="" first="" character="">
Answered Same DayJan 23, 2023

Answer To: Part 1 - Using your Geometric Progression, write a script that verifies a Geometric progression...

Vikas answered on Jan 24 2023
48 Votes
Assignment
PART – 1
starting_value = float(input("Enter the starting value: "))
r = float(input("
Enter the common ratio (make sure it is between -1 and 1 and not 0): "))
# Initialize variables
current_sum = starting_value
n = 0
# Loop until the current sum is within 0.00001 of the calculated sum
while abs(current_sum - (starting_value / (1 - r))) > 0.00001:
current_sum += starting_value * (r ** n)
n += 1
print("Current sum:", current_sum)
# Output the final sum
print("Final sum:", current_sum)
This script prompts the user to enter the starting value and...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here