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