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

Source: Internet
Author: User
Tags for in range

1. Output Hello word!

Print ("Hello Word")

2. Simple interaction

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

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

A=input ( " Please enter number a:") b=input (" Please enter number B:") c= Float (a) +float (b)print(" number {} plus number {} equals {}". Format (a,b,c))

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

Import matha=input (" input Edge length A:") b=input (" input edge length B:" c=input (" input side length C:") P= (float (a) +float (b) +float (c))/2s =math.sqrt (p* (P-float (a)) * (P-float (b)) * (P-float (c)))print(side length respectively a= {},b={},c={} has a triangle with an area of {}. Format (a,b,c,s))

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

Radius=input (" input radius:")area =3.1415*float (RADIUS) *Float (RADIUS)  Print( the area of the circle with a radius of {} is {:. 2f}" . Format (Radius,area))

6, draw a group of same cut round

 from Import * for in range (4):    pu ()    goto (0,-100)    PD ()    Circle ((I+ 1) *20)

7. Draw a Pentagram

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

8. Draw a All-yellow pentagram

Import Turtleturtle.fillcolor ("yellow") Turtle.begin_fill ()  for  in range (5):    turtle.forward (    turtle.right) (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.