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]
2 years ago
13

A python script to print fibonacci series first 20 elements

Computers and Technology
1 answer:
madreJ [45]2 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
What is information technology?
nirvana33 [79]
Information technology is the application of computers to store, retrieve, transmit and manipulate data, often in the context of a business or other enterprise. 
7 0
3 years ago
__ are designed to be used with everyday objects, such as home appliances, gaming consoles, digital cameras, e-readers, digital
LenaWriter [7]

Answer:

Embedded Operating System

Explanation:

An embedded operating system is a specialized operating system dedicated to perform a unique task for a digital device other than your desktop or laptop. For example, we can find this operating system appears in a washing machine to enable user to control the operation of the washing machine. This type of operating system is designed to be more resource efficient. An embedded operating system can also found in cars, digital television, ATM machine, digital camera etc.

3 0
2 years ago
Which of the following is the most significant outcome of the formation of the SMPTE?
olga55 [171]

Answer:

The SMPTE created an organized system of film technology, development, and distribution.

Explanation:

The SMPTE opened the door for Union organization within the film industry is true but not the most significant outcome of the formation of the SMPTE. However, the second option is certainly the most significant outcome as SMPTE is the most organized system of film technology, development, and distribution. And the other two options are also correct but the most significant outcome of the formation of the SMPTE is the second option.

7 0
2 years ago
Write a class called MagicSquare, which contains a single method called check that accepts a two-dimensional array as an argumen
ira [324]

Answer:

public class MagicSquare {

   public static void main(String[] args) {

       int[][] square = {

               { 8, 11, 14, 1},

               {13, 2, 7,12},

               { 3, 16, 9, 6},

               {10, 5, 4, 15}

       };

       System.out.printf("The square %s a magic square. %n",

               (isMagicSquare(square) ? "is" : "is not"));

   }

   public static boolean isMagicSquare(int[][] square) {

       if(square.length != square[0].length) {

           return false;

       }

       int sum = 0;

       for(int i = 0; i < square[0].length; ++i) {

           sum += square[0][i];

       }

       int d1 = 0, d2 = 0;

       for(int i = 0; i < square.length; ++i) {

           int row_sum = 0;

           int col_sum = 0;

           for(int j = 0; j < square[0].length; ++j) {

               if(i == j) {

                   d1 += square[i][j];

               }

               if(j == square.length-i-1) {

                   d2 += square[i][j];

               }

               row_sum += square[i][j];

               col_sum += square[j][i];

           }

           if(row_sum != sum || col_sum != sum) {

               return false;

           }

       }

       return d1 == sum && d2 == sum;

   }

}

5 0
2 years ago
An ________ is essentially a collection of personal computers networked together with sophisticated software tools to help group
Verdich [7]

Answer:

electronic meeting system

Explanation:

An electronic meeting system is essentially a collection of personal computers networked together with sophisticated software tools to help group members solve problems and make decisions through interactive electronic idea generation, evaluation, and voting.

8 0
2 years ago
Other questions:
  • Which loan type requires you to make loan payments while you’re attending school?
    7·1 answer
  • How do you determine latitude using an astrolabe?
    11·1 answer
  • How do i show all emails from same sender in outlook
    13·2 answers
  • What time does walmart deposit paychecks?
    5·1 answer
  • What was the best Metal Gear Solid you enjoyed the most?​
    6·1 answer
  • Jack used primarily web sources for his informative speech about gun control. however, his over-reliance on the web site sponsor
    11·1 answer
  • Which job role requires you to create user guides for computer products and services?
    11·1 answer
  • Dominic list his camera for sale on an online auction site Chloe is the highest bitter and purchase as the camera how does the a
    14·1 answer
  • How does the quantity of data affect the accuracy of an experiment?
    7·1 answer
  • Connect research concepts to their definitions
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!