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

Source: Internet
Author: User
Tags for in range

1. Hello world!

2. Simple Interactive (interactive, file-style) textbook P19

3, the user input two numbers, calculate and output two numbers of the sum:

4, the user input triangle three-side length, and calculate the area of the triangle: (Helen Formula)

A=input ("Edge length of triangle a:") b=input ("side length B of the triangle:") C=input ("The edge length of the triangle C:") s=1/2*(float(a) +float(b) +float(c) area= (s* (float(s)-float(a)) *(float(s)-float(b)) *(float(s)-float(c))) **0.5Print ("the area of the triangle is: {}". Format (area)

5. Enter the radius to calculate the area of the circle.

The radius of the circle is 5, and the area of the circle is 78.54.

6, draw a group of same cut round

Import turtleturtle.pensize (2) turtle.circle(turtle.circle) (  turtle.circle (turtle.circle)

7. Draw a Pentagram

Import Turtle  for  in range (5):      turtle.forward (+)      turtle.left ( 144)

8. Draw a All-yellow pentagram

Import Turtleturtle.color ("yellow") Turtle.fillcolor ("  Yellow") Turtle.begin_fill () for in range (5):      Turtle.forward (      turtle.left) (144) Turtle.end_fill ()

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.