I have a question for basic Python!

Asked 1 years ago, Updated 1 years ago, 217 views

I'm asking you this question because I don't know even if I try to search this and that for more than an hour I'm explaining it in words because the image is not attached.

You have to give a list statement that's already been organized as a turtleneck function and make a bar graph according to that value And for every bar graph of each value, you have to enter a number of that value above it So what I did was

import turtle
t=turtle.Turtle()
def grapic():
    mylist=[120,56,209,156,23,98]
    for i in range(1,100):
        t.width(2)
        t.left(90)
        t.forward(mylist)
        t.right(90)
        t.write(str(mylist))
        t.forward(20) 
        t.right(90)
        t.forward(mylist)

grapic()

I made it like this I have no idea Oh, and the condition is that you have to make a bar by declaring it a function Help me

python

2022-10-19 00:00

1 Answers

1. You wrote for. Why did you think you should write for? You probably wrote it because you had to repeat something. But what did I have to repeat? Should I have repeated from 1 to 100? I think 120, 56, 209... I think I should have repeated the same movement for the values I do. What do you think?

2. So what is the same movement that you have to repeat? Since it's a bar graph, go up by 120 and then write 120 just above it, then move a little to the right, up by 56 from the bottom, and then write 56 just above it. I'll have to repeat that's Can you see that everything else is the same and only 120 or 56 is different?

For some reason, I think this is all I need to give the questioner, so I'm reducing it. Try it! You can do it.

Bonus: I don't know why you've been touring from 1 to 100, but if there's a fixed width/height of the entire bar graph and you have to fill it in... Just add a little bit of a ratio calculation. If mylist obtains the maximum value and reduces it to 100, how much should 120 decrease to? The process of getting the same thing goes into the mylist circuit. If you think about it carefully, it's not difficult.


2022-10-19 00:00

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.