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

Source: Internet
Author: User
Tags arithmetic goto

  1. Hello world!
    1. Print ("Hello world!! ")
  2. Simple Interactive (interactive, file-style) textbook P19
    1. Name=input ("What is your name?\n") where=input ("where is you now?\n") Age=input ("How is old is you ? \ n")Print("your name is {}". Format (name))Print("You live in {}". Format (where)Print("You is {} years old". Format (age))
  3. The user enters two numbers and calculates and outputs the sum of two digits:
    1. Num1=input ("input a number:\n") num2=input ("input an other number:\ n")print(sum,end=" ") sum=num1+num2
  4. The user enters the triangular three-side length and calculates the area of the triangle: (Helen Formula)
  5.  a = float (input ( "  Enter first edge length:   " )) b  = float (Input (  "  Enter the second side edge length:   "  = float (input ( "  Enter the third edge length:   " )) s  = (A + B + c)/2area  = (s* (s-a) * (s-b) * (S-C) * * * 0.5print  ( "   "%area) 
  6. Enter a radius to calculate the area of the circle.
    pi=3.1415926R=float (input (" Please enter radius:"))area =pi*r*RPrint (" area of%0.2f"%area)
  7. Draw a set of identical tangent circles
    Import turtleturtle.speed (turtle.circle)turtle.circle(()turtle.circle ( ) turtle.circle (40)
  8. draw a pentagram
     import   Turtleturtle.speed (  100) Turtle.forward ( 100 144) Turtle.forward ( 100 144) Turtle.forward ( 100 144) Turtle.forward ( 100 144) Turtle.forward ( 100 144) 
  9. Draw an all-yellow pentagram
    Import turtleturtle.speed (turtle.fillcolor) ("yellow") Turtle.begin _fill (Turtle.forward)turtle.right(144) Turtle.forward (+) turtle.right(144 ) Turtle.forward (turtle.right) (144) Turtle.forward(+)turtle.right ( 144) Turtle.forward (+) turtle.right (144) Turtle.end_fill ()

Thinking:

  1. Draw a set of concentric circles.
    ImportTurtle#Draw First CircleTurtle.penup () turtle.goto (0,-200) Turtle.pendown () turtle.circle (200)#Draw Second CircleTurtle.penup () turtle.goto (0,-150) Turtle.pendown () turtle.circle (150)#Draw Third CircleTurtle.penup () turtle.goto (0,-100) Turtle.pendown () turtle.circle (100)#Draw Fourth CircleTurtle.penup () turtle.goto (0,-50) Turtle.pendown () turtle.circle (50)
  2. Draw five pentagram on the national flag

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

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.