How to draw numbers from a random list to use as Y coordinates for turtle graphicsHow do I check if a list is empty?How to randomly select an item from a list?How do you split a list into evenly sized chunks?How do I generate random integers within a specific range in Java?How to make a flat list out of list of listsGenerating random whole numbers in JavaScript in a specific range?How do I get the number of elements in a list?How do I concatenate two lists in Python?How to clone or copy a list?How do I list all files of a directory?

What license to choose for my PhD thesis?

Feedback diagram

Why wasn't interlaced CRT scanning done back and forth?

Why does Shift-right says it is bound to right?

Different answers of calculations in LuaLaTeX on local computer, lua compiler and on overleaf

Is there any difference between "result in" and "end up with"?

Skipping same old introductions

Is Norway in the Single Market?

Is there a general term for the items in a directory?

Is it moral to remove/hide certain parts of a photo, as a photographer?

Does WSL2 runs Linux in a virtual machine or alongside windows Kernel?

Can I say "Gesundheit" if someone is coughing?

Have you been refused entry into the Federal Republic of Germany?

Is an "are" omitted in this sentence

Search and replace a substring only if another substring is not present

How were x-ray diffraction patterns deciphered before computers?

What is a summary of basic Jewish metaphysics or theology?

Why is the Vasa Museum in Stockholm so Popular?

Want to manipulate and visualize differential equation of a falling object

Current in only inductive AC circuit

Proof of First Difference Property for Fourier Series

Is this popular optical illusion made of a grey-scale image with coloured lines?

Confused over role of 「自分が」in this particular passage

Subtle ways to render a planet uninhabitable



How to draw numbers from a random list to use as Y coordinates for turtle graphics


How do I check if a list is empty?How to randomly select an item from a list?How do you split a list into evenly sized chunks?How do I generate random integers within a specific range in Java?How to make a flat list out of list of listsGenerating random whole numbers in JavaScript in a specific range?How do I get the number of elements in a list?How do I concatenate two lists in Python?How to clone or copy a list?How do I list all files of a directory?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am trying to generate a list of random Y coordinates for a turtle graphics program that needs to draw flowers, but to prevent the flowers from drawing over each other I need to draw them from back to front. What I need to do is sort the random list from largest to smallest, then have it draw the flowers in that order.



I have already set up the program to generate 9 random numbers and sort them from largest to smallest, but I don't know how to draw the numbers from that list in order and assign them the Y value of the flower



This is my code for generating the random list:



def draw_stem(t,StemX,StemY):
StemYcoordinates=random.sample(range(-200,0),9)
sorted(StemYcoordinates, key=int)


But I am having trouble connecting it to this part of the code where it goes to the xy position where I want the flower to be drawn



for i in range(9):
t.setheading(90)
t.pensize(7-(StemYcoordinate//40))
t.color("#39ff14")
t.penup()
t.goto(StemX,StemYcoordinates)
t.down()


any help would be greatly appreciated










share|improve this question
























  • Welcome To SO!! Could you please supply all of your code as I can't understand what you are trying to say. When I ran it, the code gave me NameError, so please supply all of the code.

    – user11093202
    Mar 27 at 3:36











  • As for your question, do you want the turtle to go to a specific coordinate, and then start to draw the flower? If that's what you want, I can answer this question.

    – user11093202
    Mar 27 at 3:38

















0















I am trying to generate a list of random Y coordinates for a turtle graphics program that needs to draw flowers, but to prevent the flowers from drawing over each other I need to draw them from back to front. What I need to do is sort the random list from largest to smallest, then have it draw the flowers in that order.



I have already set up the program to generate 9 random numbers and sort them from largest to smallest, but I don't know how to draw the numbers from that list in order and assign them the Y value of the flower



This is my code for generating the random list:



def draw_stem(t,StemX,StemY):
StemYcoordinates=random.sample(range(-200,0),9)
sorted(StemYcoordinates, key=int)


But I am having trouble connecting it to this part of the code where it goes to the xy position where I want the flower to be drawn



for i in range(9):
t.setheading(90)
t.pensize(7-(StemYcoordinate//40))
t.color("#39ff14")
t.penup()
t.goto(StemX,StemYcoordinates)
t.down()


any help would be greatly appreciated










share|improve this question
























  • Welcome To SO!! Could you please supply all of your code as I can't understand what you are trying to say. When I ran it, the code gave me NameError, so please supply all of the code.

    – user11093202
    Mar 27 at 3:36











  • As for your question, do you want the turtle to go to a specific coordinate, and then start to draw the flower? If that's what you want, I can answer this question.

    – user11093202
    Mar 27 at 3:38













0












0








0








I am trying to generate a list of random Y coordinates for a turtle graphics program that needs to draw flowers, but to prevent the flowers from drawing over each other I need to draw them from back to front. What I need to do is sort the random list from largest to smallest, then have it draw the flowers in that order.



I have already set up the program to generate 9 random numbers and sort them from largest to smallest, but I don't know how to draw the numbers from that list in order and assign them the Y value of the flower



This is my code for generating the random list:



def draw_stem(t,StemX,StemY):
StemYcoordinates=random.sample(range(-200,0),9)
sorted(StemYcoordinates, key=int)


But I am having trouble connecting it to this part of the code where it goes to the xy position where I want the flower to be drawn



for i in range(9):
t.setheading(90)
t.pensize(7-(StemYcoordinate//40))
t.color("#39ff14")
t.penup()
t.goto(StemX,StemYcoordinates)
t.down()


any help would be greatly appreciated










share|improve this question














I am trying to generate a list of random Y coordinates for a turtle graphics program that needs to draw flowers, but to prevent the flowers from drawing over each other I need to draw them from back to front. What I need to do is sort the random list from largest to smallest, then have it draw the flowers in that order.



I have already set up the program to generate 9 random numbers and sort them from largest to smallest, but I don't know how to draw the numbers from that list in order and assign them the Y value of the flower



This is my code for generating the random list:



def draw_stem(t,StemX,StemY):
StemYcoordinates=random.sample(range(-200,0),9)
sorted(StemYcoordinates, key=int)


But I am having trouble connecting it to this part of the code where it goes to the xy position where I want the flower to be drawn



for i in range(9):
t.setheading(90)
t.pensize(7-(StemYcoordinate//40))
t.color("#39ff14")
t.penup()
t.goto(StemX,StemYcoordinates)
t.down()


any help would be greatly appreciated







python list integer turtle-graphics






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 27 at 1:17









Sebastian VillateSebastian Villate

142 bronze badges




142 bronze badges















  • Welcome To SO!! Could you please supply all of your code as I can't understand what you are trying to say. When I ran it, the code gave me NameError, so please supply all of the code.

    – user11093202
    Mar 27 at 3:36











  • As for your question, do you want the turtle to go to a specific coordinate, and then start to draw the flower? If that's what you want, I can answer this question.

    – user11093202
    Mar 27 at 3:38

















  • Welcome To SO!! Could you please supply all of your code as I can't understand what you are trying to say. When I ran it, the code gave me NameError, so please supply all of the code.

    – user11093202
    Mar 27 at 3:36











  • As for your question, do you want the turtle to go to a specific coordinate, and then start to draw the flower? If that's what you want, I can answer this question.

    – user11093202
    Mar 27 at 3:38
















Welcome To SO!! Could you please supply all of your code as I can't understand what you are trying to say. When I ran it, the code gave me NameError, so please supply all of the code.

– user11093202
Mar 27 at 3:36





Welcome To SO!! Could you please supply all of your code as I can't understand what you are trying to say. When I ran it, the code gave me NameError, so please supply all of the code.

– user11093202
Mar 27 at 3:36













As for your question, do you want the turtle to go to a specific coordinate, and then start to draw the flower? If that's what you want, I can answer this question.

– user11093202
Mar 27 at 3:38





As for your question, do you want the turtle to go to a specific coordinate, and then start to draw the flower? If that's what you want, I can answer this question.

– user11093202
Mar 27 at 3:38












2 Answers
2






active

oldest

votes


















0














I think for your code, you will need to use the setpos() method.



This method treats the screen in turtle like a coordinate plane with four quadrants.



enter image description here



Using this, set the x and y coordinates accordingly, or randomly if you want to.



For example, this puts the turtle in a random spot every time you run it:



from turtle import *
t = Turtle()
t.penup()
from random import randint
x = randint(-200, 200)
y = randint(-200, 200)
t.setpos(x, y)


Hope this Helps!!!






share|improve this answer

























  • If this answer is wrong, please tell me what I should do to improve it, as I didn't understand what you where exactly saying. English is my second language, so please do forgive me if my grammar isn't exact or anything. If you need additional help, please do ask as I am intermeddiate in python language, and begginer and javascript. Also, as a note, it helps if you supply all of your code, as I have to put the neccesary addons, and I may not know exacly what to put. Here it isn't a big deal, but when you have big programs, this becomes a huge neccesity for understanding. I geuss that's all !!!

    – user11093202
    Mar 27 at 4:57












  • With respect to, "you will need to use the setpos() method" the OP already uses t.goto(StemX,StemYcoordinates) in their code. Turtle's setpos() and setposition() methods are synonyms for turtle's goto() method.

    – cdlane
    Mar 27 at 15:45











  • @cdlane They ask how to get a place and draw the flower. I thought they had trouble getting to a spot and drawing the flower. Please correct me If I am wrong on this aspect.

    – user11093202
    Mar 28 at 4:06











  • I don't read that in the question. The closest it comes is "having trouble connecting it to this part of the code where it goes to the xy position where I want the flower to be drawn" which is about connecting two pieces of code together. Once of those pieces has a goto() which goes to a position (spot) just fine. Though this is a hard question to be sure about, as I noted in my own answer.

    – cdlane
    Mar 28 at 5:58











  • Ok My mistake @cdlane

    – user11093202
    Mar 28 at 6:04


















0














Based on the description of your problem, you seem to want something like:



from turtle import Screen, Turtle
from random import sample, random

RADIUS = 100
PETALS = 10

def draw_petal(t, radius):
heading = t.heading()
t.circle(radius, 60)
t.left(120)
t.circle(radius, 60)
t.setheading(heading)

def draw_flower(t):
for _ in range(PETALS):
draw_petal(t, RADIUS)
t.left(360 / PETALS)

def draw_flowers(t, stemX):
stemYcoordinates = sorted(sample(range(-200, 0), 9))

for stemYcoordinate in stemYcoordinates:
t.setheading(90)
t.pensize(7 + stemYcoordinate // 40)
t.color(random(), random(), random())
t.penup()
t.goto(stemX, stemYcoordinate)
t.pendown()
draw_flower(t)

screen = Screen()

turtle = Turtle(visible=False)
turtle.speed('fastest') # because I have no patience

draw_flowers(turtle, 0)

screen.exitonclick()


enter image description here



But if this isn't what you're looking for, take the time to reread and edit your question to clarify what you want to do. Add more (if not all) of the code you've written so far, to make it clear what you need help with.






share|improve this answer



























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55368406%2fhow-to-draw-numbers-from-a-random-list-to-use-as-y-coordinates-for-turtle-graphi%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I think for your code, you will need to use the setpos() method.



    This method treats the screen in turtle like a coordinate plane with four quadrants.



    enter image description here



    Using this, set the x and y coordinates accordingly, or randomly if you want to.



    For example, this puts the turtle in a random spot every time you run it:



    from turtle import *
    t = Turtle()
    t.penup()
    from random import randint
    x = randint(-200, 200)
    y = randint(-200, 200)
    t.setpos(x, y)


    Hope this Helps!!!






    share|improve this answer

























    • If this answer is wrong, please tell me what I should do to improve it, as I didn't understand what you where exactly saying. English is my second language, so please do forgive me if my grammar isn't exact or anything. If you need additional help, please do ask as I am intermeddiate in python language, and begginer and javascript. Also, as a note, it helps if you supply all of your code, as I have to put the neccesary addons, and I may not know exacly what to put. Here it isn't a big deal, but when you have big programs, this becomes a huge neccesity for understanding. I geuss that's all !!!

      – user11093202
      Mar 27 at 4:57












    • With respect to, "you will need to use the setpos() method" the OP already uses t.goto(StemX,StemYcoordinates) in their code. Turtle's setpos() and setposition() methods are synonyms for turtle's goto() method.

      – cdlane
      Mar 27 at 15:45











    • @cdlane They ask how to get a place and draw the flower. I thought they had trouble getting to a spot and drawing the flower. Please correct me If I am wrong on this aspect.

      – user11093202
      Mar 28 at 4:06











    • I don't read that in the question. The closest it comes is "having trouble connecting it to this part of the code where it goes to the xy position where I want the flower to be drawn" which is about connecting two pieces of code together. Once of those pieces has a goto() which goes to a position (spot) just fine. Though this is a hard question to be sure about, as I noted in my own answer.

      – cdlane
      Mar 28 at 5:58











    • Ok My mistake @cdlane

      – user11093202
      Mar 28 at 6:04















    0














    I think for your code, you will need to use the setpos() method.



    This method treats the screen in turtle like a coordinate plane with four quadrants.



    enter image description here



    Using this, set the x and y coordinates accordingly, or randomly if you want to.



    For example, this puts the turtle in a random spot every time you run it:



    from turtle import *
    t = Turtle()
    t.penup()
    from random import randint
    x = randint(-200, 200)
    y = randint(-200, 200)
    t.setpos(x, y)


    Hope this Helps!!!






    share|improve this answer

























    • If this answer is wrong, please tell me what I should do to improve it, as I didn't understand what you where exactly saying. English is my second language, so please do forgive me if my grammar isn't exact or anything. If you need additional help, please do ask as I am intermeddiate in python language, and begginer and javascript. Also, as a note, it helps if you supply all of your code, as I have to put the neccesary addons, and I may not know exacly what to put. Here it isn't a big deal, but when you have big programs, this becomes a huge neccesity for understanding. I geuss that's all !!!

      – user11093202
      Mar 27 at 4:57












    • With respect to, "you will need to use the setpos() method" the OP already uses t.goto(StemX,StemYcoordinates) in their code. Turtle's setpos() and setposition() methods are synonyms for turtle's goto() method.

      – cdlane
      Mar 27 at 15:45











    • @cdlane They ask how to get a place and draw the flower. I thought they had trouble getting to a spot and drawing the flower. Please correct me If I am wrong on this aspect.

      – user11093202
      Mar 28 at 4:06











    • I don't read that in the question. The closest it comes is "having trouble connecting it to this part of the code where it goes to the xy position where I want the flower to be drawn" which is about connecting two pieces of code together. Once of those pieces has a goto() which goes to a position (spot) just fine. Though this is a hard question to be sure about, as I noted in my own answer.

      – cdlane
      Mar 28 at 5:58











    • Ok My mistake @cdlane

      – user11093202
      Mar 28 at 6:04













    0












    0








    0







    I think for your code, you will need to use the setpos() method.



    This method treats the screen in turtle like a coordinate plane with four quadrants.



    enter image description here



    Using this, set the x and y coordinates accordingly, or randomly if you want to.



    For example, this puts the turtle in a random spot every time you run it:



    from turtle import *
    t = Turtle()
    t.penup()
    from random import randint
    x = randint(-200, 200)
    y = randint(-200, 200)
    t.setpos(x, y)


    Hope this Helps!!!






    share|improve this answer













    I think for your code, you will need to use the setpos() method.



    This method treats the screen in turtle like a coordinate plane with four quadrants.



    enter image description here



    Using this, set the x and y coordinates accordingly, or randomly if you want to.



    For example, this puts the turtle in a random spot every time you run it:



    from turtle import *
    t = Turtle()
    t.penup()
    from random import randint
    x = randint(-200, 200)
    y = randint(-200, 200)
    t.setpos(x, y)


    Hope this Helps!!!







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Mar 27 at 3:53







    user11093202






















    • If this answer is wrong, please tell me what I should do to improve it, as I didn't understand what you where exactly saying. English is my second language, so please do forgive me if my grammar isn't exact or anything. If you need additional help, please do ask as I am intermeddiate in python language, and begginer and javascript. Also, as a note, it helps if you supply all of your code, as I have to put the neccesary addons, and I may not know exacly what to put. Here it isn't a big deal, but when you have big programs, this becomes a huge neccesity for understanding. I geuss that's all !!!

      – user11093202
      Mar 27 at 4:57












    • With respect to, "you will need to use the setpos() method" the OP already uses t.goto(StemX,StemYcoordinates) in their code. Turtle's setpos() and setposition() methods are synonyms for turtle's goto() method.

      – cdlane
      Mar 27 at 15:45











    • @cdlane They ask how to get a place and draw the flower. I thought they had trouble getting to a spot and drawing the flower. Please correct me If I am wrong on this aspect.

      – user11093202
      Mar 28 at 4:06











    • I don't read that in the question. The closest it comes is "having trouble connecting it to this part of the code where it goes to the xy position where I want the flower to be drawn" which is about connecting two pieces of code together. Once of those pieces has a goto() which goes to a position (spot) just fine. Though this is a hard question to be sure about, as I noted in my own answer.

      – cdlane
      Mar 28 at 5:58











    • Ok My mistake @cdlane

      – user11093202
      Mar 28 at 6:04

















    • If this answer is wrong, please tell me what I should do to improve it, as I didn't understand what you where exactly saying. English is my second language, so please do forgive me if my grammar isn't exact or anything. If you need additional help, please do ask as I am intermeddiate in python language, and begginer and javascript. Also, as a note, it helps if you supply all of your code, as I have to put the neccesary addons, and I may not know exacly what to put. Here it isn't a big deal, but when you have big programs, this becomes a huge neccesity for understanding. I geuss that's all !!!

      – user11093202
      Mar 27 at 4:57












    • With respect to, "you will need to use the setpos() method" the OP already uses t.goto(StemX,StemYcoordinates) in their code. Turtle's setpos() and setposition() methods are synonyms for turtle's goto() method.

      – cdlane
      Mar 27 at 15:45











    • @cdlane They ask how to get a place and draw the flower. I thought they had trouble getting to a spot and drawing the flower. Please correct me If I am wrong on this aspect.

      – user11093202
      Mar 28 at 4:06











    • I don't read that in the question. The closest it comes is "having trouble connecting it to this part of the code where it goes to the xy position where I want the flower to be drawn" which is about connecting two pieces of code together. Once of those pieces has a goto() which goes to a position (spot) just fine. Though this is a hard question to be sure about, as I noted in my own answer.

      – cdlane
      Mar 28 at 5:58











    • Ok My mistake @cdlane

      – user11093202
      Mar 28 at 6:04
















    If this answer is wrong, please tell me what I should do to improve it, as I didn't understand what you where exactly saying. English is my second language, so please do forgive me if my grammar isn't exact or anything. If you need additional help, please do ask as I am intermeddiate in python language, and begginer and javascript. Also, as a note, it helps if you supply all of your code, as I have to put the neccesary addons, and I may not know exacly what to put. Here it isn't a big deal, but when you have big programs, this becomes a huge neccesity for understanding. I geuss that's all !!!

    – user11093202
    Mar 27 at 4:57






    If this answer is wrong, please tell me what I should do to improve it, as I didn't understand what you where exactly saying. English is my second language, so please do forgive me if my grammar isn't exact or anything. If you need additional help, please do ask as I am intermeddiate in python language, and begginer and javascript. Also, as a note, it helps if you supply all of your code, as I have to put the neccesary addons, and I may not know exacly what to put. Here it isn't a big deal, but when you have big programs, this becomes a huge neccesity for understanding. I geuss that's all !!!

    – user11093202
    Mar 27 at 4:57














    With respect to, "you will need to use the setpos() method" the OP already uses t.goto(StemX,StemYcoordinates) in their code. Turtle's setpos() and setposition() methods are synonyms for turtle's goto() method.

    – cdlane
    Mar 27 at 15:45





    With respect to, "you will need to use the setpos() method" the OP already uses t.goto(StemX,StemYcoordinates) in their code. Turtle's setpos() and setposition() methods are synonyms for turtle's goto() method.

    – cdlane
    Mar 27 at 15:45













    @cdlane They ask how to get a place and draw the flower. I thought they had trouble getting to a spot and drawing the flower. Please correct me If I am wrong on this aspect.

    – user11093202
    Mar 28 at 4:06





    @cdlane They ask how to get a place and draw the flower. I thought they had trouble getting to a spot and drawing the flower. Please correct me If I am wrong on this aspect.

    – user11093202
    Mar 28 at 4:06













    I don't read that in the question. The closest it comes is "having trouble connecting it to this part of the code where it goes to the xy position where I want the flower to be drawn" which is about connecting two pieces of code together. Once of those pieces has a goto() which goes to a position (spot) just fine. Though this is a hard question to be sure about, as I noted in my own answer.

    – cdlane
    Mar 28 at 5:58





    I don't read that in the question. The closest it comes is "having trouble connecting it to this part of the code where it goes to the xy position where I want the flower to be drawn" which is about connecting two pieces of code together. Once of those pieces has a goto() which goes to a position (spot) just fine. Though this is a hard question to be sure about, as I noted in my own answer.

    – cdlane
    Mar 28 at 5:58













    Ok My mistake @cdlane

    – user11093202
    Mar 28 at 6:04





    Ok My mistake @cdlane

    – user11093202
    Mar 28 at 6:04













    0














    Based on the description of your problem, you seem to want something like:



    from turtle import Screen, Turtle
    from random import sample, random

    RADIUS = 100
    PETALS = 10

    def draw_petal(t, radius):
    heading = t.heading()
    t.circle(radius, 60)
    t.left(120)
    t.circle(radius, 60)
    t.setheading(heading)

    def draw_flower(t):
    for _ in range(PETALS):
    draw_petal(t, RADIUS)
    t.left(360 / PETALS)

    def draw_flowers(t, stemX):
    stemYcoordinates = sorted(sample(range(-200, 0), 9))

    for stemYcoordinate in stemYcoordinates:
    t.setheading(90)
    t.pensize(7 + stemYcoordinate // 40)
    t.color(random(), random(), random())
    t.penup()
    t.goto(stemX, stemYcoordinate)
    t.pendown()
    draw_flower(t)

    screen = Screen()

    turtle = Turtle(visible=False)
    turtle.speed('fastest') # because I have no patience

    draw_flowers(turtle, 0)

    screen.exitonclick()


    enter image description here



    But if this isn't what you're looking for, take the time to reread and edit your question to clarify what you want to do. Add more (if not all) of the code you've written so far, to make it clear what you need help with.






    share|improve this answer





























      0














      Based on the description of your problem, you seem to want something like:



      from turtle import Screen, Turtle
      from random import sample, random

      RADIUS = 100
      PETALS = 10

      def draw_petal(t, radius):
      heading = t.heading()
      t.circle(radius, 60)
      t.left(120)
      t.circle(radius, 60)
      t.setheading(heading)

      def draw_flower(t):
      for _ in range(PETALS):
      draw_petal(t, RADIUS)
      t.left(360 / PETALS)

      def draw_flowers(t, stemX):
      stemYcoordinates = sorted(sample(range(-200, 0), 9))

      for stemYcoordinate in stemYcoordinates:
      t.setheading(90)
      t.pensize(7 + stemYcoordinate // 40)
      t.color(random(), random(), random())
      t.penup()
      t.goto(stemX, stemYcoordinate)
      t.pendown()
      draw_flower(t)

      screen = Screen()

      turtle = Turtle(visible=False)
      turtle.speed('fastest') # because I have no patience

      draw_flowers(turtle, 0)

      screen.exitonclick()


      enter image description here



      But if this isn't what you're looking for, take the time to reread and edit your question to clarify what you want to do. Add more (if not all) of the code you've written so far, to make it clear what you need help with.






      share|improve this answer



























        0












        0








        0







        Based on the description of your problem, you seem to want something like:



        from turtle import Screen, Turtle
        from random import sample, random

        RADIUS = 100
        PETALS = 10

        def draw_petal(t, radius):
        heading = t.heading()
        t.circle(radius, 60)
        t.left(120)
        t.circle(radius, 60)
        t.setheading(heading)

        def draw_flower(t):
        for _ in range(PETALS):
        draw_petal(t, RADIUS)
        t.left(360 / PETALS)

        def draw_flowers(t, stemX):
        stemYcoordinates = sorted(sample(range(-200, 0), 9))

        for stemYcoordinate in stemYcoordinates:
        t.setheading(90)
        t.pensize(7 + stemYcoordinate // 40)
        t.color(random(), random(), random())
        t.penup()
        t.goto(stemX, stemYcoordinate)
        t.pendown()
        draw_flower(t)

        screen = Screen()

        turtle = Turtle(visible=False)
        turtle.speed('fastest') # because I have no patience

        draw_flowers(turtle, 0)

        screen.exitonclick()


        enter image description here



        But if this isn't what you're looking for, take the time to reread and edit your question to clarify what you want to do. Add more (if not all) of the code you've written so far, to make it clear what you need help with.






        share|improve this answer













        Based on the description of your problem, you seem to want something like:



        from turtle import Screen, Turtle
        from random import sample, random

        RADIUS = 100
        PETALS = 10

        def draw_petal(t, radius):
        heading = t.heading()
        t.circle(radius, 60)
        t.left(120)
        t.circle(radius, 60)
        t.setheading(heading)

        def draw_flower(t):
        for _ in range(PETALS):
        draw_petal(t, RADIUS)
        t.left(360 / PETALS)

        def draw_flowers(t, stemX):
        stemYcoordinates = sorted(sample(range(-200, 0), 9))

        for stemYcoordinate in stemYcoordinates:
        t.setheading(90)
        t.pensize(7 + stemYcoordinate // 40)
        t.color(random(), random(), random())
        t.penup()
        t.goto(stemX, stemYcoordinate)
        t.pendown()
        draw_flower(t)

        screen = Screen()

        turtle = Turtle(visible=False)
        turtle.speed('fastest') # because I have no patience

        draw_flowers(turtle, 0)

        screen.exitonclick()


        enter image description here



        But if this isn't what you're looking for, take the time to reread and edit your question to clarify what you want to do. Add more (if not all) of the code you've written so far, to make it clear what you need help with.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 27 at 15:39









        cdlanecdlane

        22.4k3 gold badges12 silver badges48 bronze badges




        22.4k3 gold badges12 silver badges48 bronze badges






























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55368406%2fhow-to-draw-numbers-from-a-random-list-to-use-as-y-coordinates-for-turtle-graphi%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript