- Hello world!
Print ("hello,world!")
- Simple Interactive (interactive, file-style) textbook P19
Name=input (" Please enter name:")print("{} students, please study!") ". Format (name))
The user enters two numbers and calculates and outputs the sum of two digits:
N1=input ("1:") N2=input ("2:") print (float (N1) +float (n2))
- The user enters the triangular three-side length and calculates the area of the triangle: (Helen Formula)
A=input ("A:") b=input ("B:") C=input ( "C:") s= (float (a) +float (b) +float (c))/2L=float (s) * (float (s)-float (a)) * (float (s)-float (b)) * (float (s)-float (c))area =float (l) **0.5print(area)
5. Enter a radius to calculate the area of the circle.
R=input ("r:")area =3.14*float (R) *float (r)print(area)
6. Draw a set of identical tangent circles
Import turtleturtle.circle (turtle.circle) turtle.circle (100)
7. Draw a Pentagram
Import Turtleturtle.shape ("turtle") for in range (5): turtle.forward (+) turtle.left (144) Turtle.forward (+) Turtle.end_fill ()
8. Draw a All-yellow pentagram
import Turtleturtle.color ( " blue " Span style= "COLOR: #000000" >) Turtle.fillcolor ( " red " ) Turtle.begin_fill () turtle.speed ( 10) Turtle.shape ( " turtle " ) for i in range (5 100" Turtle.left ( 144) Turtle.forward ( 100) Turtle.end_fill ()
Python input and output exercises, arithmetic exercises, turtle preliminary exercises