# 鼠小弟的本领

### 鼠小弟的本领

```from sprites import *

def gxe():
"""产生关系表达式的字符串"""
s = ['>','>=','<','<=','==','!=']
a = random.randint(0,100)
b = random.randint(0,100)
express = str(a) + " " + random.choice(s) + " " +  str(b)
return express

def p1():
"""产生算术表达式并显示"""
s = ['+','-','*','/','%']
a = random.randint(1,100)
b = random.randint(1,100)
express = str(a) + " " + random.choice(s) + " " +  str(b)
text = express + " 的结果是: " + str(round(eval(express),2))
dummy.clear()
dummy.sety(120)
dummy.write("算术表达式",align='center',font=ft)
dummy.sety(40)
dummy.write(text,align='center',font=ft2)
dummy.sety(-10)
dummy.write('算术表达式用来计算数学式子的结果',align='center',font=ft3)

def p2():
"""产生关系表达式并显示"""
express = gxe()
text = express + " 的结果是: " + ('True' if eval(express) else 'False')
dummy.clear()
dummy.sety(120)
dummy.write("关系表达式",align='center',font=ft)
dummy.sety(40)
dummy.write(text,align='center',font=ft2)
dummy.sety(-10)
dummy.write('关系表达式又叫比较表达式,返回真或者假',align='center',font=ft3)

def p3():
"""产生逻辑表达式并且显示"""
s = ['not','and','or']
a = gxe()
b = gxe()
signal  = random.choice(s)
if signal == 'not':
express = signal + " " +  str(b)
else:
express = str(a) + " " + signal + " " +  str(b)
text = express + " 的结果是: " + ('True' if eval(express) else 'False')
dummy.clear()
dummy.sety(120)
dummy.write("逻辑表达式",align='center',font=ft)
dummy.sety(40)
dummy.write(text,align='center',font=ft2)
dummy.sety(-10)
dummy.write('逻辑表达式又叫布尔表达式,返回真或者假',align='center',font=ft3)

ft = ('楷体',26,'normal')
ft2 = ('arail',20,'normal')
ft3 = ('宋体',16,'normal')
frames = ['res/rat1.png','res/rat2.png']

screen = Screen()                       # 新建屏幕
screen.bgcolor('dodger blue')           # 设置底色
screen.setup(540,360)                   # 设定屏幕宽高
screen.titlebar(False)                  # 关闭标题栏
screen.draggable()                      # 按中键可拖动窗口

```

(会员专属：能浏览所有文章，下载所有带链接的Python资源。)