1、大圆的距离
import math
x1 , y1 = eval(input("enter point1 (latitude and longtitude) in degrees"))
x2 , y2 = eval(input("enter point2 (latitude and longtitude) in degrees"))
x1 = math.radians(x1)
x2 = math.radians(x2)
y1 = math.radians(y1)
y2 = math.radians(y2)
RADIUS = 6371.01
d = RADIUS * math.acos(math.sin(x1)*math.sin(x2) + math.cos(x1)\
* math.cos(x2) * math.cos(y1-y2))
print("the distance between the two points is",d,"km")
2、画一个红色的等边三角形,一个蓝色的正方形和一个绿色的正六边形。
import turtle
turtle.penup()
turtle.goto(-200,0)
turtle.pendown()
turtle.setheading(60)
turtle.color("red")
turtle.begin_fill()
turtle.circle(100,steps=3)
turtle.end_fill()
turtle.pendown()
turtle.goto(100,0)
turtle.pendown()
turtle.setheading(45)
turtle.color("blue")
turtle.begin_fill()
turtle.circle(100,steps=4)
turtle.end_fill()
turtle.pendown()
turtle.goto(400,0)
turtle.pendown()
turtle.setheading(60)
turtle.color("green")
turtle.begin_fill()
turtle.circle(100,steps=6)
turtle.end_fill()
3、用turtle画一个五环
import turtle
turtle.pensize(5)
turtle.color("blue")
turtle.penup()
turtle.goto(-110,-25)
turtle.pendown()
turtle.circle(45)
turtle.color("black")
turtle.penup()
turtle.goto(0,-25)
turtle.pendown()
turtle.circle(45)
turtle.color("red")
turtle.penup()
turtle.goto(110,-25)
turtle.pendown()
turtle.circle(45)
turtle.color("yellow")
turtle.penup()
turtle.goto(-55,-75)
turtle.pendown()
turtle.circle(45)
turtle.color("green")
turtle.penup()
turtle.goto(55,-75)
turtle.pendown()
turtle.circle(45)