Python input and output exercises, arithmetic exercises, turtle preliminary exercises

Source: Internet
Author: User
Tags arithmetic

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.