Python输入输出练习,运算练习,turtle初步练习
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python输入输出练习,运算练习,turtle初步练习相关的知识,希望对你有一定的参考价值。
1.
>>> print("Hello World") Hello World
2.
>>> name = input("输入姓名:") 输入姓名:郭靖 >>> print ("{}同学,学好python,前途无量!".format(name)) 郭靖同学,学好python,前途无量! >>> print ("{}大侠,学好python,前途无量!".format(name[0])) 郭大侠,学好python,前途无量! >>> print ("{}哥哥,学好python,人见人爱!".format(name[1])) 靖哥哥,学好python,人见人爱!
3.
n1 = input("请输入第一个数:") n2 = input("请输入第二个数:") print(float(n1) + float(n2))
4.
>>> a = float(input("a:")) a:3 >>> b = float(input("b:")) b:4 >>> c = float(input("c:")) c:5 >>> s=0.5*a*b*c >>> S=(s*(s-a)*(s-b)*(s-c))**0.5 >>> print(S) 725.6031973468695
5.
>>> r = 5 >>> area = 3.1415 * r * r >>> print(area) 78.53750000000001
6.
import turtle turtle.pensize(3) turtle.circle(10) turtle.circle(20) turtle.circle(30) turtle.circle(50) turtle.circle(80) turtle.circle(120)
7.
import turtle
turtle.pensize(2)
turtle.color("red")
turtle.forward(100)
turtle.left(144)
turtle.forward(100)
turtle.left(144)
turtle.forward(100)
turtle.left(144)
turtle.forward(100)
turtle.left(144)
turtle.forward(100)
turtle.left(144)
turtle.forward(100)
8.
import turtle turtle.pensize(2) turtle.color("red") turtle.fillcolor("red") turtle.begin_fill() turtle.forward(100) turtle.left(144) turtle.forward(100) turtle.left(144) turtle.forward(100) turtle.left(144) turtle.forward(100) turtle.left(144) turtle.forward(100) turtle.left(144) turtle.forward(100) turtle.end_fill()
以上是关于Python输入输出练习,运算练习,turtle初步练习的主要内容,如果未能解决你的问题,请参考以下文章