First, the output Hello World
Print ("Hello Word")
Second, summation operation
A1 = Input ("A1:") a2 = Input ("A2:") sum = float (A1) +float (A2) print ("The sum of the first number {0} plus the second number {1} is {2}". Format (a1,a2,sum))
Three sides of the input triangle to seek the area
Import MATHA1 = Input ("A1:") a2 = Input ("A2:") a3 = Input ("A3:") p = (float (A1) +float (A2) +float (A3))/2d=float (p) area = d* ( D-float (A1)) * (D-float (A2)) * (D-float (A3)) B=float (area) c=math.sqrt (b) print (c)
Four, the radius of the input circle, to calculate the area
Circle = input ("Radius of Circle:") area = 3.14 * Float (circle) *float (circle) print (area)
Five, no color of the pentagram
Import Turtlea = 0while A < 5: Turtle.forward ($) turtle.left (144) A = a + 1
Six, painted yellow pentagram
From Turtle Import *
FillColor ("Yellow")
Begin_fill ()
While True:
Forward (200)
Left (144)
If ABS (POS ()) <1:
Break
End_fill ()
Seven, draw the same cut round
Import Turtleturtle.pensize (8) turtle.circle (Ten) Turtle.circle () turtle.circle (+) turtle.circle (turtle.circle) (160)
Python input and output exercises, arithmetic exercises, turtle preliminary exercises