Question

Create a GUI (Graphical User Interface) in Python to graph the approximation of the Golden Spiral (Fibonacci Spiral).

34 21 13

For this purpose, you must calculate the coordinates and radio, and simulate a process of infinity using a loop.

In short, the graph must start in the lower left side corner and continue to its center infinitely.

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

# Python program for Plotting Fibonacci
# spiral fractal using Turtle
import turtle
import math

def fiboPlot(n):
   a = 0
   b = 1
   square_a = a
   square_b = b

   # Setting the colour of the plotting pen to blue
   x.pencolor("black")

   # Drawing the first square
   x.forward(b * factor)
   x.left(90)
   x.forward(b * factor)
   x.left(90)
   x.forward(b * factor)
   x.left(90)
   x.forward(b * factor)

   # Proceeding in the Fibonacci Series
   temp = square_b
   square_b = square_b + square_a
   square_a = temp
  
   # Drawing the rest of the squares
   for i in range(1, n):
       x.backward(square_a * factor)
       x.right(90)
       x.forward(square_b * factor)
       x.left(90)
       x.forward(square_b * factor)
       x.left(90)
       x.forward(square_b * factor)

       # Proceeding in the Fibonacci Series
       temp = square_b
       square_b = square_b + square_a
       square_a = temp

   # Bringing the pen to starting point of the spiral plot
   x.penup()
   x.setposition(factor, 0)
   x.seth(0)
   x.pendown()

   # Setting the colour of the plotting pen to red
   x.pencolor("black")

   # Fibonacci Spiral Plot
   x.left(90)
   for i in range(n):
       print(b)
       fdwd = math.pi * b * factor / 2
       fdwd /= 90
       for j in range(90):
           x.forward(fdwd)
           x.left(1)
       temp = a
       a = b
       b = temp + b


# Here 'factor' signifies the multiplicative
# factor which expands or shrinks the scale
# of the plot by a certain factor.
factor = 1

# Taking Input for the number of
# Iterations our Algorithm will run
n = int(input('Enter the number of iterations (must be > 1): '))

# Plotting the Fibonacci Spiral Fractal
# and printing the corresponding Fibonacci Number
if n > 0:
   print("Fibonacci series for", n, "elements :")
   x = turtle.Turtle()
   x.speed(100)
   fiboPlot(n)
   turtle.done()
else:
   print("Number of iterations must be > 0")

Add a comment
Know the answer?
Add Answer to:
Create a GUI (Graphical User Interface) in Python to graph the approximation of the Golden Spiral...
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
  • Using Python’s tkinter Graphical User Interface (GUI) module create a Python program to input the number...

    Using Python’s tkinter Graphical User Interface (GUI) module create a Python program to input the number of each type of coin a user has in their possession and then compute and display the total dollar and cents value of these coins. Your solution must accommodate Dollar, Half-Dollar, Quarter, Dime, Nickel, and Penny coins. Your solution must be robust against invalid inputs (i.e., negative value entered into any coin entry widget).

  • I. User Interface Create a JavaFX application with a graphical user interface (GUI) based on the...

    I. User Interface Create a JavaFX application with a graphical user interface (GUI) based on the attached “GUI Mock-Up”. Write code to display each of the following screens in the GUI: A. A main screen, showing the following controls: • buttons for “Add”, “Modify”, “Delete”, “Search” for parts and products, and “Exit” • lists for parts and products • text boxes for searching for parts and products • title labels for parts, products, and the application title B. An add...

  • Using Dr Java Objective: Create a game of video poker with a graphical user interface (GUI)....

    Using Dr Java Objective: Create a game of video poker with a graphical user interface (GUI). The player should start with $100, and then the system deals out 5 playing cards. After the player sees the cards they are then asked to wager $10, $20, $50, or $100. Next the user picks which cards they wish to throw away, and then the system deals more cards in their place. Once this has concluded money are awarded by these criteria: Nothing...

  • Write a MATLAB Graphical User Interface (GUI) to simulate and plot the projectile motion – the...

    Write a MATLAB Graphical User Interface (GUI) to simulate and plot the projectile motion – the motion of an object projected into the air at an angle. The object flies in the air until the projectile returns to the horizontal axis (x-axis), where y=0. This MATLAB program should allow the user to try to hit a 2-m diameter target on the x-axis (y=0) by varying conditions, including the lunch direction, the speed of the lunch, the projectile’s size, and the...

  • I need to make javafx GUI application called Email that implements a prototype user interface for...

    I need to make javafx GUI application called Email that implements a prototype user interface for composing email message. The application should have labelled text fields for To, cc,bcc ,subject line, one for message body and button lebelled Send. When we click Send button, the program should print contents of all fields to standard output using println() statement. I am attaching photos of Email.java and EmailPane.java, I need to make it as per these classes CylinderSta.. Cylinder java MultiCylind.. ....

  • Questions 1. How to create a comment in python? 2. The way to obtain user input...

    Questions 1. How to create a comment in python? 2. The way to obtain user input from command line 3. List standard mathematical operators in python and explain them 4. List comparison operators in python 5. Explain while loop. Give example 6. Explain for loop. Give example 7. How to create infinite loop? And how to stop it? 8. Explain a built-in function ‘range’ for ‘for’ loop 9. Explain break statement 10. Explain continue statement 11. Explain pass statement 12....

  • Infinite Spiral of Numbers (due 17 Feb 2020) HELLO, WE ARE USING PYTHON 3 TO COMPLETE...

    Infinite Spiral of Numbers (due 17 Feb 2020) HELLO, WE ARE USING PYTHON 3 TO COMPLETE THIS PROJECT!! PLEASE FOLLOW CODE SKELETON AS GIVEN AT THE END. THIS IS DUE 17TH FEB 2020, ANY AND ALL HELP WOULD BE GREATLY APPRECIATED, THANK YOU! Consider the natural numbers laid out in a square spiral, with 1 occupying the center of the spiral. The central 11 x 11 subset of that spiral is shown in the table below. 111 112 113 114...

  • You need not run Python programs on a computer in solving the following problems. Place your...

    You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...

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
Active Questions
ADVERTISEMENT