- 博客(9)
- 收藏
- 关注
原创 DOM对象方法---removeChild(),insertBefore()
一些DOM对象方法:removeChild(),insertBefore()
2022-07-23 18:58:07 437 1
原创 Python编程实践:类和对象 问题:鹦鹉学舌,定义类 Bage(八哥),使之能随机复述听过的话。
import randomclass Bage: def __init__(self): self.sentences = [] def hear(self,a): self.sentences.append(a) def repeat(self): start=0 end=len(self.sentences) if end: i=random.ran...
2022-04-17 21:09:33 1066
原创 Python编程实践 turtle实例 美国队长盾牌
import turtle as tt.penup()t.goto(0,-200)t.pendown()t.color("red")t.begin_fill()t.circle(200),t.end_fill()t.penup()t.goto(0,-150)t.pendown()t.color("white")t.begin_fill()t.circle(150)t.end_fill()t.penup()t.goto(0,-100)t.pendown()t.co.
2022-04-13 23:13:01 1688
原创 Python编程实践之计算列表 stu 中每个学生的平均分,并添加到数据末尾
fo=open("stu.txt","r+")data=[]while True: words=fo.readline() if words=='':break if words.endswith('\n'): words=words[:-1] data.append(words.split(',')for i in range(len(data)): for j in range(len(data[i])): ...
2022-04-12 22:09:18 1452
原创 Python编程实践之谢尔宾斯基三角形
def mysqrt(x,a,b): if b-a<0.0000001: return b m=(a+b)/2 if m*m>x: return mysqrt(x,a,m) else: return mysqrt(x,m,b)print(mysqrt(2,1,2))import math,turtle as tdef trangle(len): for i in range(3): t.fd(le...
2022-04-10 21:38:10 1030
原创 Python编程实践:字典逆向查找(reverse lookup),根据值 value 从字典中查找并返回其 key。●示例:lookup({‘a‘:4, ‘b‘:5, ‘c‘:6}, 4),返回 ‘
def lookup(get_value): look = {'a':4, 'b':5, 'c':4} if get_value in look.values(): return(list(look.keys())[list(look.values()).index(get_value)]) else: return noneres=lookup(4)print(res)解析:look.keys就是取出字典lookup所...
2022-04-08 23:54:38 1324
原创 编写一个函数mysum,以整数列表为参数,返回所以元素之和。
def mysum(List): sum=0 for item in List: sum+=item return sumList=[1,2,3]res=mysum(List)print(res)
2022-04-01 21:41:41 2777
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人