python课堂练习

简单交互
>>> name = input("输入姓名:")
输入姓名:郭靖
>>> print ("{}同学,学好python,前途无量!".format(name))
郭靖同学,学好python,前途无量!
>>> print ("{}大侠,学好python,前途无量!".format(name[0]))
郭大侠,学好python,前途无量!
>>> print ("{}哥哥,学好python,人见人爱!".format(name[1]))
靖哥哥,学好python,人见人爱!
画一个同切圆
import turtle
turtle.pensize(3)
turtle.circle(10)
turtle.circle(20)
turtle.circle(30)
turtle.circle(50)
turtle.circle(80)
turtle.circle(120)
画一个五角星
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)
半径为5的圆的面积
r = 5
area = 3.1415 * r * r
print(area)
78.53750000000001
海伦公式
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)
画一个全红的五角星
 1 import turtle
 2 turtle.color('red')
 3 turtle.forward(100)
 4 turtle.right(144)
 5 turtle.forward(100)
 6 turtle.right(144)
 7 turtle.forward(100)
 8 turtle.right(144)
 9 turtle.forward(100)
10 turtle.right(144)
11 turtle.forward(100)
hello word
print("Hello World")
Hello World
两数之和
n1 = input("请输入第一个数:")
n2 = input("请输入第二个数:")
print(float(n1) + float(n2))

 

 

转载于:https://www.cnblogs.com/garxiu/p/7483770.html

你可能感兴趣的:(python课堂练习)