python练习题(2)

简介: python练习题(2)

1,人民币韩元汇率转换实例


此处借鉴温度转换的实例,进行相应的练习。温度转换

#一人民币等于200韩元
#curExchange.py
curExchange = input("请输入带有符号的货币值:")
if curExchange[-1] in ['₩']:
  CNY = (eval(curExchange[0:-1]))*0.005
  print("可兑换的人民币为%.3f"%CNY)
elif curExchange[-1] in ['¥']:
  KRW = (eval(curExchange[0:-1]))*200
  print("可兑换的韩元为%.3f"%KRW)
  print("思密达")
else:
  print("输入有误")


2,九环靶子实例


import turtle
turtle.Screen().setup(600,600,0,0)
for i in range(1,9):
    turtle.circle(10*i)
    turtle.penup()
    turtle.goto(0,-10*i)
    turtle.pendown()
turtle.done()


3,太极图实例


#太极图
import turtle as t
# 设置笔的移动速度及大小
t.speed(10)
t.pensize(6)
# 画黑色的半圆
t.fillcolor("black")
t.begin_fill()
t.circle(100,180)
t.left(0)
t.circle(50,180)
t.circle(-50,180)
t.end_fill()
# 画白色的半圆
t.fillcolor("white")
t.begin_fill()
t.circle(-100,180)
t.left(180)
t.circle(50,180)
t.circle(-50,180)
t.end_fill()
# 在黑圆画白色的点
t.left(180)
t.up()
t.goto(10,150)
t.down()
t.pencolor("white")
t.fillcolor("white")
t.begin_fill()
t.circle(13)
t.end_fill()
# 在白圆画黑色的点
t.up()
t.goto(-10,30)
t.fillcolor("black")
t.begin_fill()
t.circle(15)
t.end_fill()
t.pencolor('blue')
t.goto(1000,1000)
t.done()


结尾:2,3以turtle库练习为主

相关文章
|
4月前
|
存储 Python
Python经典练习题(四)
Python经典练习题(四)
Python经典练习题(四)
|
4月前
|
存储 Web App开发 开发者
Python 自动化指南(繁琐工作自动化)第二版:附录 C:练习题的答案
Python 自动化指南(繁琐工作自动化)第二版:附录 C:练习题的答案
59 0
|
12月前
|
存储 Python
Python经典练习题(三)
Python经典练习题(三)
|
3月前
|
Python
python练习题
python练习题
|
4月前
|
存储 索引 Python
【python】——组合数据类型(单选练习题)
【python】——组合数据类型(单选练习题)
|
4月前
|
算法 Python
python文件读取操作练习题(统计单词)
python文件读取操作练习题(统计单词)
104 0
|
12月前
|
Python
Python经典练习题(二)
Python经典练习题(二)
|
12月前
|
Python
Python经典练习题(一)
Python经典练习题(一)
|
Python
Python|PTA练习题
Python|PTA练习题
116 0