课堂练习

一、输出hello world

print('hello world’)
Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 17:54:52) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> 
================ RESTART: C:/Users/Administrator/Desktop/1.py ================
hello world
>>> 
二、求和运算

a1 = input("a1:")
a2 = input("a2:")
sum = float(a1)+float(a2)
print(sum)
================ RESTART: C:/Users/Administrator/Desktop/1.py ================
a1:1
a2:2
3.0
三、求三角形的面积

import math
a= input("a:")
b= input("b:")
c= input("c:")
d=(float(a)+float(b)+float(c))/2
e=float(d)
area =e*(e-float(a))*(e-float(b))*(e-float(c))
f=float(area)
g=math.sqrt(f)
print(f)
================ RESTART: C:/Users/Administrator/Desktop/1.py ================
a:4
b:5
c:6
98.4375
四、圆的面积

Circle = input("R :")
area = 3.1415926 * float(Circle)*float(Circle)
print(area)
================ RESTART: C:/Users/Administrator/Desktop/1.py ================
R :3
28.274333400000003
五、画五角星

import turtle
a = 0
while a < 5:
    turtle.forward(200)
    turtle.left(144)
    a = a + 1

  

六、画黄色五角星

from turtle import *
fillcolor("yellow")
begin_fill()
while True:
    forward(200)
    right(144)
    if abs(pos())< 1:
        break
end_fill()

  

 

 

  

 

posted on 2017-09-07 12:21  55卢思凯  阅读(153)  评论(0编辑  收藏  举报