Python Little Exercise

Source: Internet
Author: User

1.Hello world!

Print (' Hello world! ')

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

Name = input ("Enter name:") print ("{} students, learn python, promising!") . Format (name) print ("{} heroes, learn Python, promising!") . Format (name[0)) print ("{} sister, learn python, promising!") ". Format (name[1:]))

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

Print ("Result:%.2f"% (float (input (' Enter first variable: ') +float (input (' Input second variable: ')))

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

A=float (Input ("Enter the first edge of the triangle:")) B=float (Input ("Enter the second edge of the Triangle:")) C=float (Input ("Please enter the third edge of the triangle:")) P=float ((a+b+c)/2) Area=float ((p* (P-A) * (p-b) * (p-c)) **0.5) print ("area:%.2f"%area)

5, input radius, calculate the area of the circle

Radius = Float (Input circle radius: ")" area = Float (3.1415 * radius * radius) print ("%.2f"%area)

6, draw a group of same cut round

Import turtleturtle.circle (turtle.circle) turtle.circle (+) turtle.circle (+) turtle.circle (turtle.circle) (60)

7. Draw a Pentagram

Import Turtleturtle.forward (turtle.right) Turtle.forward (Turtle.forward) turtle.right (180) Turtle.right (Turtle.forward) turtle.right (+) Turtle.forward (180)

8. Draw a All-yellow pentagram

Import Turtleturtle.bgcolor ("Red") Turtle.color ("Yellow") Turtle.fillcolor ("Yellow") Turtle.begin_fill () Turtle.forward (Turtle.right) (144) Turtle.forward (144) turtle.right (144) Turtle.forward (+) Turtle.forward (Turtle.right) (144) Turtle.forward () Turtle.end_fill ()

  

Python Little Exercise

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.