## current position：Home>Python----Draw a square and inscribed circle, enter the total number of points, so that the points are randomly and evenly distributed in the square and circle ()

# Python----Draw a square and inscribed circle, enter the total number of points, so that the points are randomly and evenly distributed in the square and circle ()

2022-11-08 07:20:04【will be open today】

**turtle.geto(x,y): Set the brush start point function (use the center of the screen as the origin to establish a plane rectangular coordinate system)**

**turtle.dot(number): The size of the dot when drawing a dot**

**turtle.tracer(1000) and turtle.update():**

Speed up the drawing, refresh every 1000 times, otherwise there will be a drawing process (slower)

Speed up the drawing, refresh every 1000 times, otherwise there will be a drawing process (slower)

`import random,turtle,math#turtle.goto(x,y) turtle.dot(5), the side length is 800n=eval(input())#Enter the total number of pointsturtle.tracer(1000)turtle.update()#Speed up the painting, refresh once every 1000 times, if not, there will be a painting processturtle.pensize(1)turtle.pencolor("blue")turtle.penup()turtle.goto(-400,-400)turtle.pendown()for i in range(4):turtle.fd(800)turtle.left(90)#'To the leftturtle.fd(400)#straightforward400pxturtle.pencolor("red")turtle.circle(400)for i in range(n):x,y=random.random()*400,random.random()*400signx,signy=random.choice("+-"),random.choice("+-")turtle.penup()#Randomly generate positive and negative coordinatesturtle.goto(eval(signx+str(x)), eval(signy+str(y)))if math. sqrt(eval(signx+str(x))**2+eval(signy+str(y))**2)<=400:#Distinguish inside the circle (red) and outside the circle (blue)turtle.pencolor("red")else:turtle.pencolor("blue")turtle.pendown()turtle.dot(10)turtle.done()`

copyright notice

author[will be open today],Please bring the original link to reprint, thank you.

https://en.pythonmana.com/2022/312/202211080628358251.html

## The sidebar is recommended

- I wrote a financial data crawler in Python, and I did the work of the interns for a week in half an hour
- Python project combat - bank ATM system (3)
- Python decimal to binary function_python hexadecimal to binary
- Python toolbox series (12)
- python automatic send mail script
- [Study Notes] Introduction to Deep Learning: Theory and Implementation Based on Python
- How python handles program exceptions
- Python Volunteer Management System Based on PHP+MySQL
- python is based on PHP+MySQL university asset management system
- Python is based on PHP+MySQL reading sharing platform

## guess what you like

Python student association management system based on PHP+MySQL

Notes for python importing other modules under windows

What exactly does Python's __pycache__ cache?Can the historical running results be cached?- A little research on PyCache

Compare similarity of two vectors - python

Boutique flower sales shopping mall applet based on Python

python get all files in current directory

python gets computer CPU, motherboard, BIOS, hard disk serial number, host name, IP, Mac address

python get computer unique identifier

Python converts strings to hexadecimal (encryption and decryption)

python based on PHP+MySQL college students job recruitment website

## Random recommended

- Linear sieve prime number template (Python/C++)
- python university student health management system based on PHP+MySQL
- Python Deep Learning in Action: Testing Neural Networks
- UE4 gets HTTP interface data (UE4 communicates with python)
- Ask a complex text processing problem Python
- Talking about list creation and list element addition and deletion in Python
- Python finds the average mutual information of English text
- Python performance optimization example exercise
- python script rewrite yaml
- Python NotImplementedError: cannot instantiate 'PosixPath' on your system
- How far can a Python novice learn to do automation?
- [Bluebridge Cup for Python] day_008: Huffuman tree
- Install the GDAL library in Python
- Python classic questions finishing
- Python - function design and use
- October 2022 Python Cabin Programming Contest Winners List (Free 5 Books)
- Introduction to Python Interesting Algorithms - Newton's Iterative Method to Find Equation Roots
- Introduction to Python Fun Algorithms - Catch Traffic Accidents & Best Deposit Schemes
- Introduction to Interesting Algorithms in Python - How Much Do You Know About Borrowing Solutions
- Python writes a small game: snake chess (below)
- Introduction to Python Interesting Algorithms - Rabbit Childbirth (Intrinsic Logic of Fibonacci Sequences)
- Getting Started with Interesting Algorithms in Python Develop Paper
- Upgrading Python Packages with Pip
- Python extracts video frames and saves them as images - target detection
- To revisit the Python list base - operation
- {0:2d} {1:3d} {2:4d}'.format(x, x * x, x * x * x) understanding in Python
- Python's pickle method for simple information management
- Python basic exercises (4)
- Python basic exercises (3)
- The pushback of python scrolling at any point in time
- Revisiting Python Basics - Numbers
- python: basics
- Object-Oriented Polymorphism in Python
- Python basics (suitable for beginners - complete tutorial - learning time for about a week - saving your time)
- Python foundation 05 - dictionary: dict and set: set, reading this article is enough
- After learning JsonPath, your Python interface script is complete
- The three main modules of Python that novice Xiaobai should know
- Install python3.8.9 in Linux environment
- Python---- Monte Carlo method to find Π, stopwatch function
- Python----scientific notation, assigning multiple variables at the same time, eval function, math library function, complex number (complex()), built-in numerical operation function, built-in numerical operation operator