The answer in this blog is not from official resources, but from my own exercises, which may be incorrect.
8-9. Fibonacci series. The Fibonacci sequence is like 1, 1, 2, 3, 5, 8, 13, and 21. That is to say, the next value is the sum of the first two values in the sequence. Write a function. Given N, return the nth Fibonacci number. For example, the 1st Fibonacci numbers are 1 and the 6th are 8.
[Answer]
The Code is as follows:
Def maid (number): fs = [0, 1] I = 1 for I in range (number-1 ): a = fs [-1] + fs [-2] fs. append (a) I + = 1 print fs [1:] return fs [-1] number = raw_input ("Please input a number... ") print maid (int (number ))
[Execution result]
Please input a number... 10 [1, 1, 2, 3, 5, 8, 13, 21, 34, 55] 55
8-10. Text Processing. Count the number of metachines, consonants, and words (separated by spaces) in a sentence. Ignore special situations of vowels and consonants, such as "h", "y", and "qu. Additional question: write the code to handle these special situations.
[Answer] I feel a little difficult at present. This question can only be left behind.
Keywords: Pyhon core programming answers unofficial