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

Source: Internet
Author: User
Tags arithmetic

Hello world!

Print ("Hello Word")

Simple Interactive (interactive, file-style) textbook P19

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 = float (input ('input triangle First side length:')) b= Float (Input ('input Triangle Second side length:')) C= Float (Input ('input triangle Third side length:'))#Calculate half Perimeters = (A + B + c)/2Print('triangular half-perimeter is%0.2f'%s)#calculate area with Helen Formula S=√[p (P-A) (p-b) (p-c)]{a,b,c for edge length, p for half perimeter = (a+b+c)/2}Area = (s* (s-a) * (s-b) * (S-C)) * * 0.5Print('triangular area of%0.2f'%area)

Enter a radius to calculate the area of the circle.

pi=3.14= float (input ("))#  calculates the area of the circle areas = pi*r*r  Print(' Circle area of%0.2f' %area)

Draw a set of identical tangent circles

Import ($) (100 )

Draw a Pentagram

Import turtleturtle.hideturtle () turtle.speed()Turtle.begin_fill ()  for  in range (5):        turtle.forward (    turtle.left(144) Turtle.end_fill ( )

Draw an all-yellow pentagram

Import turtleturtle.hideturtle () turtle.speed()turtle.color ("green" ) ) Turtle.fillcolor ("green") Turtle.begin_fill ()for in Range (5):        turtle.forward (+)    turtle.left (144) Turtle.end_fill () 

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

Related Article

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