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

Source: Internet
Author: User

First, the output Hello World

Print ("Hello Word")

Second, summation operation

A1 = input ("A1:"= input ("A2:"= float (A1) + float (A2) Print (" the first number {0} plus the second number {1} and is {2}". Format (a1,a2,sum))

Three sides of the input triangle to seek the area

Import= input ("A1:"= input ("A2:"  = input ("A3:"= (float (A1) +float (A2) +float (A3))/2D == 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 (" Circle Radius:"= 3.14 * FLOAT (circle) *float (circle)Print (area)

Five, no color of the pentagram

Import= 0 while a < 5:    turtle.forward ($)    Turtle.left (144)    = 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) (40 ) turtle.circle (turtle.circle) (160)

Eight, simple interaction

Name = input (" Enter name:")print("{} classmate, learn Python, promising!")  ". Format (name))

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

Related Article

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.