摘要: 代码: student_grade_input.txt 101,刘晨曦,88 102,王雨轩,98 103,王祎伟,90 104,李威,70 105,景少帅,99 106,周泽宇,96 p013_compute_max_min_avg.py def compute_score(): scores=[ 阅读全文
posted @ 2021-10-29 12:38 scholar-for-ever 阅读(47) 评论(0) 推荐(0) 编辑
摘要: 代码: def read_file(): result=[] with open("./student_grade_input.txt") as fin: for line in fin: line=line[:-1] result.append(line.split(",")) return re 阅读全文
posted @ 2021-10-24 19:46 scholar-for-ever 阅读(31) 评论(0) 推荐(0) 编辑
摘要: 代码: import random list=["xyla","tom","hrh","monkey","c","b","a","2","1"] i=int(input("Please enter an integer: ")) while i!=100: j=random.sample(list, 阅读全文
posted @ 2021-10-24 16:23 scholar-for-ever 阅读(324) 评论(0) 推荐(0) 编辑
摘要: 代码: def shengxiao(year): zodiac=["鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"] i= (year-1900)%12 j=zodiac[i] return j myyear=int(input("Please ente 阅读全文
posted @ 2021-10-24 15:50 scholar-for-ever 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 代码: def match_num(num): f=[6,2,5,5,4,5,6,3,7,6] if num==0: total=f[0] else: total=0 while num>0: x=num%10 total=total+f[x] num=num//10 return total sn 阅读全文
posted @ 2021-10-24 01:47 scholar-for-ever 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 代码: for i in range(1,10): for j in range(1,i+1): print("{0:1}*{1:1}={2:<2} ".format(j,i,j*i),end="") print() 效果: 1*1=1 1*2=2 2*2=4 1*3=3 2*3=6 3*3=9 1 阅读全文
posted @ 2021-10-22 10:59 scholar-for-ever 阅读(43) 评论(0) 推荐(0) 编辑
摘要: 代码: import pdb money=50000 rate=[0.0325,0.03,0.03,0.02,0.0175] for i in rate: money=round(money+money*i,2) print("Five years later,your wealth is:",mo 阅读全文
posted @ 2021-10-21 22:03 scholar-for-ever 阅读(86) 评论(0) 推荐(0) 编辑
摘要: 代码: students=[ {"sno":101,"sname":"刘晨曦","sgrade":88}, {"sno":102,"sname":"王雨轩","sgrade":98}, {"sno":103,"sname":"王祎伟","sgrade":90}, {"sno":104,"sname" 阅读全文
posted @ 2021-10-21 13:25 scholar-for-ever 阅读(38) 评论(0) 推荐(0) 编辑
摘要: 代码: i=0 while i<100: print(i) i+=1 j=0 sum=0 while j<=100: sum=sum+j j+=1 print(sum) 效果: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 阅读全文
posted @ 2021-10-20 13:25 scholar-for-ever 阅读(34) 评论(0) 推荐(0) 编辑
摘要: 代码: for i in range(100): print(i) sum=0 for j in range(101): sum+=j print(sum) 效果: 0 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 阅读全文
posted @ 2021-10-20 12:49 scholar-for-ever 阅读(23) 评论(0) 推荐(0) 编辑