Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update turtle_graphics.py #128

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nikitapandeyy
Copy link

some issues in the code:

The abs() function cannot be applied to turtle positions directly. To calculate the distance between two positions, you can use the distance() method of the turtle object.

The sample() function from the random module is used to select a single element from a list. However, it returns a list of one element. In this code, the [0] index is used to extract the single element from the returned list. It's simpler to use the choice() function from the random module to select a single element directly.

The size variable is used to determine the length of the sides of the polygon to be drawn. However, the polygon may go off the screen if the size is too large. To prevent this, you can use the window_height() and window_width() functions from the turtle module to calculate the maximum size that can be used without going off the screen.

There is no need to use tt.done() at the end of the code as the turtle window will close automatically when the user closes the window.

some issues in the code:

The abs() function cannot be applied to turtle positions directly. To calculate the distance between two positions, you can use the distance() method of the turtle object.

The sample() function from the random module is used to select a single element from a list. However, it returns a list of one element. In this code, the [0] index is used to extract the single element from the returned list. It's simpler to use the choice() function from the random module to select a single element directly.

The size variable is used to determine the length of the sides of the polygon to be drawn. However, the polygon may go off the screen if the size is too large. To prevent this, you can use the window_height() and window_width() functions from the turtle module to calculate the maximum size that can be used without going off the screen.

There is no need to use tt.done() at the end of the code as the turtle window will close automatically when the user closes the window.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant