I have this code
When generation count =1 , perform inner loop 2 times
When generation count = 2, perform inner loop 4 times
when generation count = 3, perform inner loop 8 times
when generation count = 4, perform inner loop 16 times
.....you see that the inner loop is always performed twice as many times as it was performed last time.
Anything to point me on my way to code the inner loop multiples would be very appreciated.
For an expert I think this will be a straightforward one.
THANKS
mike
#import the graphical interface
from tkinter import *
#creat root widget
x1 = 10
y1 = 10
x2 = 20
y2 = 20
root = Tk()
root.title('Evolution - Two Brancher')
root.geometry("600x600")
my_canvas = Canvas(root, width=300, height=300, bg="yellow")
#pady pushes canvas down the screen a little
my_canvas.pack(pady=30)
#create line (start x1, y1 end x2, y2, fill="colour")
Perform_branching_this_no_of_times = 0
generation_count = 1
while generation_count < 10:
#generation growth
#inner loop
while Perform_branching_this_no_of_times < 10:
Perform_branching_this_no_of_times = Perform_branching_this_no_of_times + 1
my_canvas.create_line(x1, y1, x2, y2, fill="black")
x1 = x2
y1 = y2
x2 = x2 + 10
y2 = y2 + 20
my_canvas.create_line(x1, y1, x2, y2, fill="black")
x2 = y2
y2 = x2
my_canvas.create_line(x1, y1, x2, y2, fill="black")
generation_count = generation_count + 1
root.mainloop()QUESTION\PROBLEM - I am very new to Python.Looking at code above , for generations 1 to 10, I wanted to perform the inner loop a different number for times, each time. To be exactWhen generation count =1 , perform inner loop 2 times
When generation count = 2, perform inner loop 4 times
when generation count = 3, perform inner loop 8 times
when generation count = 4, perform inner loop 16 times
.....you see that the inner loop is always performed twice as many times as it was performed last time.
Anything to point me on my way to code the inner loop multiples would be very appreciated.
For an expert I think this will be a straightforward one.
THANKS
mike
