I really need help with this python programming assignment
Program Requirements
For part 1, I need a program with 2 functions specifically these
• fib(): Takes a single integer argument num terms greater than or equal to 1 and for each
of the num terms terms of the Fibonacci sequence prints 1) the number of the term—i.e., 1,
2, 3..., 2) the corresponding Fibonacci number, and 3) the ratio of the current and previous Fibonacci
numbers as shown below. The ratio, printed only for x1 and higher, is an approximation
of the golden ratio = 1.61803398875...
• main(): Prompts the user for the number of terms s/he wants to find and calls the void function
fib().
The program giving the following output
1 Enter the number of terms you want to find: 2
2 1 1
3 2 1 1.0
1 Enter the number of terms you want to find: 9
2 1 1
3 2 1 1.0
4 3 2 2.0
5 4 3 1.5
6 5 5 1.66666666667
7 6 8 1.6
8 7 13 1.625
9 8 21 1.61538461538
10 9 34 1.61904761905
The last line of your program should be a call to main(). Don't forget to include docstrings!
How many terms are needed to obtain an approximation to the golden ratio accurate to 4 decimal
places?
def fib(n):
a = 1 # setting initial values
b = 1
for i in range(n): # looping for n times
print(a, b, b/a) # printing the output
a, b = b, a+b # updating the numbers
def main():
n = int(input("Enter the number of terms you want to find: "))
fib(n)
main()
''' Sample Output
Enter the number of terms you want to find: 9
1 1 1.0
1 2 2.0
2 3 1.5
3 5 1.6666666666666667
5 8 1.6
8 13 1.625
13 21 1.6153846153846154
21 34 1.619047619047619
34 55 1.6176470588235294
'''
# Hit the thumbs up if you are fine with the answer. Happy Learning!
I really need help with this python programming assignment Program Requirements For part 1, I need...
I really need help with this python programming assignment Program Requirements For part 2, i need the following functions • get floats(): It take a single integer argument and returns a list of floats. where it was something like this def get_floats(n): lst = [] for i in range(1,n+1): val = float(input('Enter float '+str(i)+': ')) lst.append(val) return lst • summer(): This non-void function takes a single list argument, and returns the sum of the list. However, it does not use...
PYTHON 3 - please show format Question 2. ) Use the Design Recipe to write a function yesOrNo which has no parameters. When called, it gets input from the user until the user types either 'yes' or 'no', at which point the function should return True if the user typed 'yes' and False if the user typed 'no'. Any other entries by the user are ignored and another value must be input. For example: Test Input Result print(yesOrNo()) hello blank...
Fibonacci Sequence The Fibonacci Sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ... The next number is found by adding up the two numbers before it. The 2 is found by adding the two numbers before it (1+1) The 3 is found by adding the two numbers before it (1+2), And the 5 is (2+3), and so on! Example: the next number in the sequence above is 21+34 = 55 Source:...
Multi-threaded programming help!!! Can anyone solve this
problem? It has to be written in C, runs on Linux.
his time you need to rewrite a multithreaded Pthread program that works with sleep() or pthread_join() in order to print out Fibonacci sequences properly. Create a folder name, WK6 on your class Linux machine when you work. gcc assignment3.c-Wall -Werror -pthread You are required to develop your own program using C with the following information Need to declare a function that receives...
Programming Exercise 11.6 Х + | Instructions fib.py >_ Terminal + iit B 1 def fib(n): 2 "*"Returns the nth Fibonacci number. " 3 if n < 3: lil 4 return 1 Modify the recursive Fibonacci function to employ the memoization technique discussed in this chapter. The function creates a dictionary and then defines a nested recursive helper function named memoizedFib You will need to create a dictionary to cache the sum of the fib function. The base case of...
Programming C....... function code is clear but compile is wrong .. I input 8 and compiled 2 0 1 1 2 3 5 8 13.. look first number 2 is wrong. The correct answer 8 is 0 1 1 2 3 5 8 13 21.. Need fix code to compile correctly.. Here code.c --------------------------------------------------------------------------------------------------------------------- #include <stdio.h> #include <math.h> int fibonacciIterative( int n ) { int fib[1000]; int i; fib[ 0 ] = 0; fib[ 1 ] = 1; for (...
Done in matlab
In mathematics, two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. a + b a for a b>0 Mathematicians since Euclid have studied the properties of the golden ratio, including its appearance in the dimensions of a regular pentagon and in a golden rectangle, which may be cut into a square and a smaller rectangle with the same aspect ratio....
I really need help with this python programming assignment
asap
please double check indentations, thank you
We were unable to transcribe this imageEnter a drink option: Milk 22 Guest #1: a Please select the number of your entree choice 1) Planked salmon, 2) Prime rib, 3) Sesame tofu with spinach: 3 Please select the number of your dessert choice 27 1) Caramel oat bar, 2) Chocolate decadence, 3) Orange creme brulee: 1 Please select the number of your drink choice...
- In python language doing a programming assignment that requires: 1-your calculateor must recieve two numbers from the user and one operator("+" for sum,"-" for sub,"*"for multiplication,"/" for division,"^" for exponentiation,@,for"root extraction and "% for modulo). 2-you must creat a code to find the n the fibonacci number, where n is a number input by the user. -Remember that a Fibonacci number is given by the sum of the two previous numbers in the sequence: Fib(n)=Fib(n-1)+fib(n-2)