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