自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(89)
  • 收藏
  • 关注

原创 浙大版《Python 程序设计》题目集 第7章-1 词频统计 (30分)

import reimport collectionsimport syswords = "".join([line for line in sys.stdin])words = re.compile(r"\w+", re.I).findall(words.lower().split('#')[0])words = [each.strip() for each in words]wor...

2020-03-07 12:14:19 1761 1

原创 浙大版《Python 程序设计》题目集 第6章-8 *6-7 输出全排列 (20分)

import randomdef factorial(n): s = 1 for i in range(1,n+1): s *= i return sn = int(input())li = []s = set()for i in range(1,n+1): li.append(str(i))total = factorial(n)w...

2020-03-07 12:13:46 553

原创 浙大版《Python 程序设计》题目集 第6章-7 找出总分最高的学生 (15分)

n = int(input())li= []total_list = []for i in range(n): ID,name,s1,s2,s3 = input().split() s1,s2,s3 = int(s1),int(s2),int(s3) total = s1+s2+s3 a = [ID,name,s1,s2,s3,total] total...

2020-03-07 12:13:09 2010

原创 浙大版《Python 程序设计》题目集 第6章-6 求指定层的元素个数 (40分)

def get_n(li,layer,signal): if signal == layer: return len([i for i in li if type(i)!=list]) else: return sum([get_n(i,layer+1,signal) for i in li if type(i)==list])li = eval(...

2020-03-07 12:11:59 349

原创 浙大版《Python 程序设计》题目集 第6章-5 列表元素个数的加权和(1) (40分)

def get_n(each,layer): s = 0 if type(each)!=list: s += layer else: layer += 1 for i in each: s +=get_n(i,layer) return sli = eval(inpu...

2020-03-07 12:11:09 320

原创 浙大版《Python 程序设计》题目集 第6章-4 列表数字元素加权和(1) (40分)

def get_n(each,layer): s = 0 if type(each)==int: s += each*layer elif type(each)==str: pass else: layer += 1 for i in each: s +=get_n(i,laye...

2020-03-07 12:10:17 458

原创 浙大版《Python 程序设计》题目集 第6章-3 列表或元组的数字元素求和 (20分)

def get_n(each): s = 0 if type(each)==int: s += each elif type(each)==str: pass else: for i in each: s +=get_n(i) return sli = eval(input())s ...

2020-03-06 11:36:19 435

原创 浙大版《Python 程序设计》题目集 第6章-2 一帮一 (15分)

n = int(input())li = []match = {}for i in range(n): gender,name = input().split() li.append((gender,name))top_list = li[:int(n/2)]bottom_list = list(reversed(li[int(n/2):]))for i in top_...

2020-03-06 11:35:44 691

原创 浙大版《Python 程序设计》题目集 第6章-1 输入列表,求列表元素和(eval输入应用) (10分)

li = eval(input())s = sum(li)print(s)

2020-03-06 11:35:05 330

原创 浙大版《Python 程序设计》题目集 第5章-11 字典合并 (40分)

d1 = eval(input())d2 = eval(input())d_str = {}d_digit = {}d_final = {}for i in d1: if type(i)==int: d_digit[i] = d1[i] elif type(i)==str: d_str[i] = d1[i]for j in d2: ...

2020-03-06 10:50:41 925

原创 浙大版《Python 程序设计》题目集 第5章-10 两数之和 (30分)

number_list = list(map(int,input().split(',')))n = int(input())flag = 0for i in number_list: for j in number_list[number_list.index(i)+1:]: s = i + j if s == n: prin...

2020-03-06 10:50:07 381

原创 浙大版《Python 程序设计》题目集 第5章-9 求矩阵鞍点的个数 (30分)

import numpy as npn = int(input())arr_list = []max_num_list = []for i in range(n): li = list(map(int,input().split())) arr_list.append(li) max_num = max(li) h_idx = i for v_idx...

2020-03-06 10:49:33 432

原创 浙大版《Python 程序设计》题目集 第5章-8 能被3,5和7整除的数的个数(用集合实现) (30分)

a,b = map(int,input().split())count = 0for i in range(a,b+1): if i%3==0 and i%5==0 and i%7==0: count += 1print(count)

2020-03-06 10:48:57 1097

原创 浙大版《Python 程序设计》题目集 第5章-7 列表去重 (40分)

li = eval(input())li2 = []for each in li: if each not in li2: li2.append(each)li3 = [str(i) for i in li2]print(' '.join(li3))

2020-03-06 10:48:33 660

原创 浙大版《Python 程序设计》题目集 第5章-6 统计工龄 (20分)

n = int(input())li = list(map(int,input().split()))list_set = set(li)dic = {}for each in list_set: count = li.count(each) dic[each] = countfor key,value in dic.items(): print('{}:{}'....

2020-03-06 10:47:55 483

原创 浙大版《Python 程序设计》题目集 第5章-5 统计字符出现次数 (20分)

s = input()a = input()count = 0for i in s: if i == a: count += 1print(count)

2020-03-06 10:46:57 698

原创 浙大版《Python 程序设计》题目集 第5章-4 分析活动投票情况 (20分)

li = set(map(int,input().split(',')))lst = []for each in li: if each in list(range(6,11)): lst.append(each)lst_not = []for i in range(6,11): if i not in lst: lst_not.append...

2020-03-05 14:38:39 449 1

原创 浙大版《Python 程序设计》题目集 第5章-3 四则运算(用字典实现) (30分)

a = int(input())b = input()c = int(input())dict1 = {'+':'a+c','-':'a-c','*':'a*c','/':"a/c if c!=0 else 'divided by zero'"}s = eval(dict1[b])if type(s) == str: print(s)else: print('{:.2f...

2020-03-05 14:37:04 597

原创 浙大版《Python 程序设计》题目集 第5章-2 图的字典表示 (20分)

n = int(input())li = []vertax = nlen_edge = 0sum_edge = 0for i in range(n): d = eval(input()) li.append(d)for each in li: for key in each: temp = each[key] len_edge +...

2020-03-05 14:36:33 679

原创 浙大版《Python 程序设计》题目集 第5章-1 输出星期名缩写 (70分)

dict_calendar = {'1':'Mon','2':'Tue','3':'Wed','4':'Thu','5':'Fri','6':'Sat','7':'Sun'}n = input()print(dict_calendar.get(n))

2020-03-05 14:35:58 573

原创 浙大版《Python 程序设计》题目集 第4章-30 找完数 (20分)

import mathm,n = map(int,input().split())factor_list = []flag = 0for i in range(m,n+1): factor_list.append(1) for j in range(2,int(math.sqrt(i))+1): if i%j == 0: factor_...

2020-03-05 14:24:35 989

原创 浙大版《Python 程序设计》题目集 第4章-29 找出不是两个数组共有的元素 (20分)

M = list(map(int,input().split()))[1:]N = list(map(int,input().split()))[1:]not_dup = []for each in M: if each not in N and each not in not_dup: not_dup.append(each)for each in N: ...

2020-03-05 14:23:12 769

原创 浙大版《Python 程序设计》题目集 第4章-28 矩阵转置 (10分)

import numpy as nparr_list = []li = list(map(int,input().split()))for i in range(3): arr_list.append(li[i*3:i*3+3])arr = np.array(arr_list).Tfor i in range(3): for j in range(3): ...

2020-03-05 14:22:37 723

原创 浙大版《Python 程序设计》题目集 第4章-27 二维数组中每行最大值和每行和 (10分)

li = list(map(int,input().split()))h_list = []for i in range(1,4): for j in range(1,4): idx = 3*(i-1)+j - 1 print('{:4d}'.format(li[idx]),end='') h_list.append(li[idx]) ...

2020-03-05 14:22:18 1343

原创 浙大版《Python 程序设计》题目集 第4章-26 求1!+3!+5!+……+n! (10分)

def factorial(n): s = 1 for i in range(1,n+1): s *= i return sn = int(input())s = sum([factorial(i) for i in range(1,n+1,2)])print('n=%d,s=%d' % (n,s))

2020-03-05 14:21:33 1567

原创 浙大版《Python 程序设计》题目集 第4章-25 输出三角形字符阵列 (15分)

n = int(input())raw_li = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')number = sum(range(1,n+1))li = raw_li[:number]count = 0for each in li: count += 1 print(each,end=' ') if count == n and coun...

2020-03-05 14:20:59 641

原创 浙大版《Python 程序设计》题目集 第4章-24 打印九九口诀表 (15分)

N = int(input())for i in range(1,N+1): for j in range(1,i+1): print('{}*{}={:<4d}'.format(j,i,j*i),end='') if j == i: print()

2020-03-04 10:21:35 470

原创 浙大版《Python 程序设计》题目集 第4章-23 求矩阵的局部极大值 (15分)

import numpy as npM,N = map(int,input().split())arr_list = []for i in range(M): li = list(map(int,input().split())) arr_list.append(li)arr = np.array(arr_list)flag = 0for i in range(1,M-...

2020-03-04 10:21:09 539

原创 浙大版《Python 程序设计》题目集 第4章-22 找鞍点 (20分)

import numpy as npn = int(input())arr_list = []max_num_list = []for i in range(n): li = list(map(int,input().split())) arr_list.append(li) max_num = max(li) h_idx = i for v_idx...

2020-03-04 10:20:24 771

原创 浙大版《Python 程序设计》题目集 第4章-21 判断上三角矩阵 (15分)

def isright(): n = int(input()) count = 0 flag = 1 for i in range(n): count += 1 li = list(map(int,input().split())) if count != 1: for i in range(c...

2020-03-04 10:19:56 371

原创 浙大版《Python 程序设计》题目集 第4章-20 求矩阵各行元素之和 (15分)

m,n = map(int,input().split())li= []for i in range(m): s = sum(list(map(int,input().split()))) li.append(s)for each in li: print(each)

2020-03-04 10:18:36 355

原创 浙大版《Python 程序设计》题目集 第4章-19 矩阵运算 (20分)

n = int(input())s= 0count = 0for i in range(n): count += 1 li = list(map(int,input().split())) del li[-1] if count != 1: del li[-count+1] if count == n: li = []...

2020-03-04 10:17:48 551

原创 浙大版《Python 程序设计》题目集 第4章-18 猴子选大王 (20分)

li = list(range(1,int(input())+1))count = 0while len(li)>1: for i in li[:]: count += 1 if count == 3: count = 0 li.remove(i)print(li[0])

2020-03-04 10:17:01 822

原创 浙大版《Python 程序设计》题目集 第4章-17 水仙花数(20 分) (20分)

n = int(input())min_num = 10 ** (n-1)max_num = 10 ** ns = 0count = nfor i in range(min_num,max_num): temp = i while count >= 1: a = temp%10 temp = temp//10 s +=...

2020-03-04 10:15:28 830

原创 浙大版《Python 程序设计》题目集 第4章-16 jmu-python-判断是否构成三角形 (10分)

a,b,c = map(int,input().split())if a+b>c and a+c>b and b+c>a: print('yes')else: print('no')

2020-03-04 10:12:07 932

原创 浙大版《Python 程序设计》题目集 第4章-15 换硬币 (20分)

n = int(input())count = 0for a in range(int(n/5),0,-1): for b in range(n//2,0,-1): c = n - 2*b - a*5 if c > 0: print('fen5:{}, fen2:{}, fen1:{}, total:{}'.format(a...

2020-03-04 10:11:33 593

原创 浙大版《Python 程序设计》题目集 第4章-14 统计字符 (15分)

def input_10(): n = input() while len(n) < 10: n += '\n' + input() return nn = input_10()letter,blank,digit,other = 0,0,0,0for each in n: if each.isalpha(): lette...

2020-03-03 10:49:07 446

原创 浙大版《Python 程序设计》题目集 第4章-13 求误差小于输入值的e的近似值 (20分)

def factiorial(n): prod = 1 for i in range(1,n+1): prod *= i return proddef e(n): return sum([1/factiorial(i) for i in range(n+1) ])error = float(input())for i in range(10...

2020-03-03 10:45:43 513

原创 浙大版《Python 程序设计》题目集 第4章-12 求满足条件的斐波那契数 (30分)

def f(n): fn1 = 1 fn2 = 1 fn3 = 1 while n > 2: fn3 = fn1 + fn2 fn1 = fn2 fn2 = fn3 n -= 1 return fn3n = int(input())for i in range(1,n): if...

2020-03-03 10:44:18 443

原创 浙大版《Python 程序设计》题目集 第4章-11 判断素数 (20分)

def isprime(n): if n == 1: return False else: for i in range(2,n): if n%i==0: return False else: return Truen = int(input())l...

2020-03-03 10:42:00 590

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除