Python Lab Ex 9seeders: 0
leechers: 0
Python Lab Ex 9 (Size: 1.69 KB)
Description
L9.2 Exercises Exercise L9.E1 – The Fibonacci sequence is defined with an integer n as, F(n) = F(n1) F(n2) for n = 2, where F(0) = 0,F(1) = 1. You have to develop a Python program to compute F(n) for a given integer n between 0 and 20. Input: 0 < n < 20 Output: F(n) < 2^32 Compute F(n) starting with n=2 and increment iteratively until the required value is obtained. Follow the instructions below. 1. Create a text file named “FileIn.txt” containing the value of n . The text file needs to be saved in the same folder where the source file has been saved. 2. Develop a Python function named “getNum” to read the number n from the file “FileIn.txt”. 3. Develop a Python function named “show” to display the given value n and the computed value of F(n) on the screen. 4. Develop a Python function named “saveFile” to write what was displayed in (3) above to a text file named “result.txt”. This file should be in the same folder where the source file is. 5. The program should call the appropriate functions to achieve the task. Related Torrents
Sharing Widget |