Question

Write a python program that implements the Fibonacci series while also using class object framework for...

Write a python program that implements the Fibonacci series while also using class object framework for python 2

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please let me know if anything is required. Please follow the indentation as shown in the code screenshot.

Code screenshot:

Sample output1:

Sample output2:

Copyable code:

class FibanacciSeries:
x=0
p1=1
p2=1
def __init__(self, x=0,p1=1,p2=1): #the constructor
self.x = x
def get_x(self): #getter for x
return self._x
def set_x(self, x): #setter for x
self._x = int(x)
def displaySeries(self,x): #FibanacciSeries method
print("The Fibanacci Series: ")#printing the series
for i in range(x):
print (self.p1,end=" ")
temp=self.p1
self.p1=self.p2
self.p2=temp+self.p2
print()
  
  

obj = FibanacciSeries() #object to the class FibanacciSeries class
x=input("Enter the number: ")#taking the number from the user
obj.set_x(x)
obj.displaySeries(obj.get_x()) #displaying the menu

  
  
  

Add a comment
Know the answer?
Add Answer to:
Write a python program that implements the Fibonacci series while also using class object framework for...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a python program using Object Oriented and do the following: 1. create class "cat" with...

    Write a python program using Object Oriented and do the following: 1. create class "cat" with the following properties: name, age (create constructor method: def __init__) 2. create class "adopter" with the following properties: name, phone 3. create class "transaction" with these properties: adopter, cat (above objects) cat1 = "puffy, 2" adopter1 = "Joe, 123" Test your program: Joe adopts puffy. Print: "Per Transaction 1 <joe> has adopted <puffy>" this can only be done with object oriented programming, no way...

  • Write a Python program that implements the Towers of Hanoi, using the recursive algorithm discussed in...

    Write a Python program that implements the Towers of Hanoi, using the recursive algorithm discussed in class. Use command-line arguments to pass parameters to the program - spring% python towersOfHanoi.py USAGE: towersOfHanoi.py <# rings> <FROM peg> <TO peg> spring% python towersOfHanoi.py 4 1 3 Move disk from peg 1 to peg 2 Move disk from peg 1 to peg 3 Move disk from peg 2 to peg 3 Move disk from peg 1 to peg 2 Move disk from peg...

  • Write a program that implements the pseudocode in python by using turtle like below: Repeat 45...

    Write a program that implements the pseudocode in python by using turtle like below: Repeat 45 times: Walk forward 100 steps Turn right 92 degrees Walk forward 10 steps Turn right 92 degrees

  • Questions 3 Write a Python program that implements the following functionality: 1. Makes an LED blink....

    Questions 3 Write a Python program that implements the following functionality: 1. Makes an LED blink. 2. Then, on a push of a button the blinking stops. 3. Then, on another push of a button the blinking starts again 4. The behavior of steps 2 and 3 keeps repeating whenever the button is pushed. In writing your program, you should use a class, call it Blinkclass, that helps in making the LED blink or not. Connect the needed circuit using...

  • Write a program that uses a while loop to read in a series of test scores,...

    Write a program that uses a while loop to read in a series of test scores, then calculates the average. Control the number of repetitions by using a sentinel value. In python ty

  • QUESTION 3 40 points Sense Write a Python program using recursion that implements the exponential function...

    QUESTION 3 40 points Sense Write a Python program using recursion that implements the exponential function ered by the following equation et = 1 + 2 + 1 Test your tinction for x5 Altach File row My Compute it. Che Sage N rowe Detox o te Chi SunSubmit

  • Write a Java program that generates an array of Fibonacci numbers. Specifications: The program -Fills a...

    Write a Java program that generates an array of Fibonacci numbers. Specifications: The program -Fills a one-dimensional array with the first 30 Fibonacci numbers using a calculation to generate the numbers. Note: The first two Fibonacci numbers 0 and 1 should be generated explicitly as in -long[] series = new long[limit]; //create first 2 series elements series[0] = 0; series[1] = 1; -But, it is not permissible to fill the array explicitly with the Fibonacci series’ after the first two...

  • Write a program that implements a Course class. Write a demo class that implements two instances...

    Write a program that implements a Course class. Write a demo class that implements two instances of the Course class. The Course class shall have the following member properties and methods: Course - courseName: String - courseAbbr: String - courseNumber: int - courseSection: int - maxNumOfStudents: int + numberOfCourseInstances: int + Course (courseName: String, courseAbbr: String, courseNumber: int, courseSection: int) : void + setCourseName(courseName: String) : void + setCourseAbbr (courseAbbr : String): void + setCourseNumber (courseNumber : int): void +...

  • Python 3.6 "While Loops" Write a program that adds up a series of numbers entered by...

    Python 3.6 "While Loops" Write a program that adds up a series of numbers entered by the user. The user should enter each number at the command prompt. The user will indicate that he or she is finished entering the number by entering the number 0.   Example This program will sum a series of numbers. Enter the next number (enter 0 when finished) > 5 Enter the next number (enter 0 when finished) > 2 Enter the next number (enter...

  • IN PYTHON USING IDLE PLATFORM PLEASE ALSO POST CODE TO COPY PLEASE Write a PYTHON Program...

    IN PYTHON USING IDLE PLATFORM PLEASE ALSO POST CODE TO COPY PLEASE Write a PYTHON Program that will ask the user for a base number then the program should display the multiplication table of that number up to 12.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT