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

Source: Internet
Author: User

1. Hello world!
`Print ("hello,world!")`

2. Simple Interactive (interactive, file-style) textbook P19
`Name=input (" Please enter name:")print("{} students, please study!")  ". Format (name))`

3. 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))`

4. 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

Related Keywords:
Related Article

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.