1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
sp2606 [1]
3 years ago
13

A python script to print fibonacci series first 20 elements

Computers and Technology
1 answer:
madreJ [45]3 years ago
5 0

Answer:

   nterms =20

   # first two terms

   n1, n2 = 0, 1

   count = 0

   # check if the number of terms is valid

   if nterms <= 0:

      print("Please enter a positive integer")

   elif nterms == 1:

      print("Fibonacci sequence upto",nterms,":")

      print(n1)

   else:

      print("Fibonacci sequence:")

      while count < nterms:

          print(n1)

          nth = n1 + n2

          # update values

          n1 = n2

          n2 = nth

          count += 1

Explanation:

Here, we store the number of terms in nterms. We initialize the first term to 0 and the second term to 1.

If the number of terms is more than 2, we use a while loop to find the next term in the sequence by adding the preceding two terms. We then interchange the variables (update it) and continue on with the process.

<em>output:</em>

Fibonacci sequence:

0

1

1

2

3

5

8

You might be interested in
40 points
NNADVOKAT [17]

Answer:

repetition and balance

Explanation:

4 0
3 years ago
Read 2 more answers
In which type of market do farmers sell their produce directly to village traders in rural areas?
Anna007 [38]

Answer:

Local Market or Primary Market.

Explanation:

The farmers sell their products to big traders in the bigger market in the urban areas. However, they also sell a part of their products to various village traders, who are located in the rural areas and can be found in local or primary markets. It's not so that they are not useful as well, as small farmers, in fact, sell the whole of their produce in the local or primary market as we know them by name. And the farmer gets a reasonable return there as well.

8 0
3 years ago
Select the best answer to the following question.
Fittoniya [83]

Answer:

I think its called "cloud computing"

8 0
3 years ago
What are the elements of a good study environment? Check all that apply.
finlep [7]

The elements of a good study environment are that it must be well lit the resources are near it is quite and it is clutter free

Explanation:

A good study environment must be an environment that will promote the good study conditions and it must be quite and calm if a person studies in that environment all the resources like the food water and the other refreshments must be available in that environment

The environment must be clean and it must be clutter free without any disturbances and hence these are the factors that will promote the good study environment

3 0
3 years ago
Read 2 more answers
Which form of currency is not backed by gold today
Len [333]
I think it might be the USD but I'm not sure. 
5 0
4 years ago
Other questions:
  • The first step in the five-step process for problem solving is to ____. evaluate take action understand the task or need complet
    10·2 answers
  • What video game has made the most money as of 2016?
    15·2 answers
  • Which describes the first step a crawler-based search engine uses to find information?
    10·2 answers
  • Your team will write a function that reverses a C-string, to practice using pointers. You must use pointers and C-strings for th
    6·1 answer
  • Write a program that:
    13·1 answer
  • There are several design goals in building an operating system; for example, resource utilization, timeliness, robustness and so
    11·1 answer
  • 54 points!!! Cyber security
    14·1 answer
  • Rita tried unsuccessfully to open a PDF file attachment in her Inbox by double-clicking the attachment in the Reading Pane. What
    8·1 answer
  • 1. Who was the first lady programmer?​
    14·2 answers
  • Sistem komponen mekanikal yang terdapat pada sebuah basikal?​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!