npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

python2103b

v1.0.0

Published

据说是黄淮学院数应2103B,python必考的题,可能不会考

Readme

四个python文件对应四个题,看图片,据说要考

自己调试一下

1,请定义一个Dog类,类属性有名字(name)毛发(color)体重(weight)方法叫(wangwang)调用该方法时输出wangwang,使用Dog类创建一个对象,名字为旺财,毛色为黄色,体重为10,并调用wangwang方法

class Dog:
    def __init__(self,name,color,weight):
        self.name=name
        self.color=color
        self.weight=weight
    def wangwang(self):
        print("wang!wang!")
d= Dog("旺财","黄色",10)
d.wangwang()
print(d.name)
print(d.color)
print(d.weight)

2,编写程序,定义一个Circle类,有属性半径,get_circumference(),计算并输出圆的周长,方法get_area()计算并输出圆的面积。创建好类后,创建一个圆对象进行测试

class Circle:
    def __init__(self,r):
        self.r=r
    def get_circumference(self):
        l=2*3.14*self.r
        print(l)
    def get_area(self):
        s=3.14*self.r*self.r
        print(s)
c=Circle(10)
c.get_circumference()
c.get_area()

3,编写一个猜数游戏

import tkinter as tk
import random
x=random.randint(0,100)
def f():
    guess=int(en.get())
    if x==guess:
        la.config(text=f"恭喜你猜对了")
    elif x>guess:
        la.config(text="很遗憾,你猜小了")
    else:
        la.config(text=f"很遗憾,你猜大了")
def g():
    pass
root=tk.Tk()
root.title("猜数游戏")
la=tk.Label(text="请输入0-100之间任意整数:")
en=tk.Entry(root)
la.pack(side=tk.TOP)
en.pack(side=tk.LEFT)
tk.Button(text="猜",width=20,command=f).pack(side=tk.LEFT)
tk.Button(text="关闭",width=20,command=g).pack(side=tk.LEFT)
root.mainloop()

4,求e的近似值

def factoria(n):
    if n==1:
        return 1
    return n*factoria(n-1)
def calculate_e(m):
    e=1
    while m:
        t=factoria(m)
        e=e+1/t
        m-=1
    print(e)
m=int(input("请输入循环次数m:"))
calculate_e(m)