HW #4.py - #Purpose: to ask user for a number X amount of...

This preview shows page 1 out of 1 page.

The preview shows page 1 - 1 out of 1 page.
#Purpose: to ask user for a number X amount of times#Assumption: program will run through w while loop#inputs: int, string#Post-condition: print the sum of all the numbers entereddef sumTotal(x):num = 0i = 0while i < x:number = eval(input("Enter a number: "))num = num + numberi = i + 1sum1 = num / (x)print(sum1)#Purpose: to get a fibonacci number#Assumption:it will be able to compute the fibanachi number#inputs: int#Post-condition: a number will be returneddef Fibonacci(n):if n == 0:return 0if n>1:return Fibonacci(n-1) + Fibonacci(n-2)if n == 1:return 1#Purpose: to use def function and execute the code
End of preview. Want to read the entire page?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
professor_unknown
Tags
Fibonacci number, Golden ratio, number X amount of times

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture