随笔 - 23  文章 - 0  评论 - 0  阅读 - 11594
 
摘要: 在安装pip的出现异常提示: ERROR: Could not find a version that satisfies the requirement pillow (from versions: none) ERROR: No matching distribution found for p 阅读全文
posted @ 2023-01-07 22:22 至清无物 阅读(1121) 评论(0) 推荐(0) 编辑
  2023年1月10日
class Dog():
    def __init__(self,D_breed,D_name,D_age,D_gender):
        self.breed=D_breed
        self.name=D_name
        self.age=D_age
        self.gender=D_gender

    def look_home(self):
        print(f'{self.name}在看家')

    def eat_bone(self):
        print(f'{self.name}在啃骨头')
d=Dog('拉布拉多','小妞',2,'')
d.look_home()
d.eat_bone()

class Person():
    def __init__(self,name,age):
        self.name=name
        self.age=age

    def check_name(self):
        print(f'我的名字是{self.name},我今年{self.age}岁')
p=Person('xx',3)
p.check_name()
#小明爱跑步,爱吃东西,小明体重75公斤,每次跑步会减肥0.5公斤,每次吃东西体重会增加1公斤
class Person():
    def __init__(self,p_name,p_weight):
        self.name=p_name
        self.weight=p_weight

    def eat(self):
        self.weight+=1
        print(f'好吃佬,该减肥了,现在体重是:{self.weight}公斤')

    def run(self):
        self.weight-=0.5
        print(f'运动,令人保持健康的身材,现在体重是:{self.weight}公斤')

p=Person('小明',75)
p.eat()
p.run()
#设计一个Circle(圆)类,包括圆心点位置、半径等属性,方法有计算周长和面积,创建一个圆的对象,获取该圆的周长和面积,
# 以及其他点和圆的关系【点的坐标可以使用元组表示(0,0)】
class Circle():
    def __init__(self,c_p,c_r):
        self.cp=c_p
        self.cr=c_r

    def c_length(self):
        return 2*3.14*self.cr

    def c_area(self):
        return 3.14*self.cr**2

    def relation(self,other_p):
        distance=(self.cp[0]-other_p[0])**2+(self.cp[1]-other_p[1])**2
        pow_r=self.cr**2
        if distance>pow_r:
            return '圆外'
        elif distance<pow_r:
            return '圆内'
        else:
            return '圆上'

c=Circle((0,0),10)
print(f'半径为{c.cr}的圆,周长是{c.c_length():.2f},面积是{c.c_area():.2f},同时这一点在{c.relation([0,10])}')
#猫类的属性有昵称name、年龄age,方法有抓老鼠
#鼠类的属性有昵称name,创建猫对象信息为5岁的Tom猫,创建老鼠对象信息名为jerry,执行猫爪老鼠的行为一只5岁的Tom猫抓到一只名为jerry的老鼠

class Cat():
    def __init__(self,c_name,c_age):
        self.name=c_name
        self.age=c_age

    def catch(self,mouse):
        print(f'一只{self.age}岁的{self.name}猫抓到了一只名为{mouse.name}的老鼠')

class Mouse():
    def __init__(self,m_name):
        self.name=m_name

mouse=Mouse('Jerry')
cat=Cat('Tom',5)
cat.catch(mouse)

 

posted @ 2023-01-10 20:29 至清无物 阅读(190) 评论(0) 推荐(0) 编辑
  2023年1月9日
摘要: #导入模块 import datetime,time,tkinter #新建一个窗口 windows=tkinter.Tk() #给窗口定义标题 windows.title('简易计算器') #给窗口定义尺寸 windows.geometry('500x600') # 逻辑事件 content='' 阅读全文
posted @ 2023-01-09 21:16 至清无物 阅读(109) 评论(0) 推荐(0) 编辑
摘要: #题目:纸厚0.08mm,折几次可以达到珠穆朗玛峰8848.13米的高度 m_height=8848.13*1000 z_height=oldz_height=0.08 #计数器 count=0 #利用循环方法1: while z_height<m_height: z_height*=2 count 阅读全文
posted @ 2023-01-09 16:33 至清无物 阅读(366) 评论(0) 推荐(0) 编辑
摘要: #母鸡三元一只,公鸡一元一只,小鸡0.5元一只,一百元全部买鸡,有多少种不同买法,分别是什么? count=0 for m_j in range(1,100//3): for g_j in range(1,100): for x_j in range(2,101,2): if(m_j+g_j+x_j 阅读全文
posted @ 2023-01-09 16:31 至清无物 阅读(682) 评论(0) 推荐(0) 编辑
摘要: import tkinter,random,tkinter.messagebox #创建窗口 window=tkinter.Tk() #设置窗口大小 window.geometry('500x500') #设置窗口标题 window.title('猜字游戏界面') # 数据逻辑 good_price 阅读全文
posted @ 2023-01-09 16:28 至清无物 阅读(525) 评论(0) 推荐(0) 编辑
  2023年1月8日
摘要: # 引用PTL图片 from PIL import Image # 打开图片 image=Image.open('./image/1.JPG') # 打印图片 print(image) # 显示图片image.show() # 打印图片的尺寸、模式、具体信息、格式化信息 print(image.si 阅读全文
posted @ 2023-01-08 20:21 至清无物 阅读(213) 评论(0) 推荐(0) 编辑
摘要: # 乘法口诀 for x in range(1,10): for y in range(1,x+1): print(f'{y}x{x}={x*y}', end='\t') print() print('\n') # 加法口诀 for x in range(1,10): for y in range( 阅读全文
posted @ 2023-01-08 20:17 至清无物 阅读(742) 评论(0) 推荐(0) 编辑
摘要: #求随机三个数是水仙花数 num=random.randint(100,999) hundred=num // 100 decade=num % 100 // 10 ones=num % 10 if hundred ** 3 +decade ** 3 +ones ** 3 == num: print 阅读全文
posted @ 2023-01-08 20:12 至清无物 阅读(145) 评论(0) 推荐(0) 编辑
摘要: #求闰年和平年 year=random.randint(1900,2023) if (year % 4 ==0 and year % 100 !=0) or (year % 400 ==0): print(f'{year}年是百年一遇的闰年,顺顺利利') else: print(f'现在是{year 阅读全文
posted @ 2023-01-08 20:05 至清无物 阅读(221) 评论(0) 推荐(0) 编辑
摘要: import random #求随机能被3和5同时整除的数 num=random.randint(1,1000) if num % 3==0 and num % 5 ==0: print(f'数字{num}可以被3和5整除') elif num % 3 ==0: print(f'数字{num}可以被 阅读全文
posted @ 2023-01-08 20:04 至清无物 阅读(116) 评论(0) 推荐(0) 编辑
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示