文库 真题 NOC真题

2023年NOC大赛Python复赛初中组真题

NOC大赛真题 NOC复赛真题 PDF   7页   下载0   2024-05-03   浏览108   收藏0   点赞0   评分-   免费文档
温馨提示:当前文档最多只能预览 2 页,若文档总页数超出了 2 页,请下载原文档以浏览全部内容。
2023年NOC大赛Python复赛初中组真题 第1页
2023年NOC大赛Python复赛初中组真题 第2页
剩余5页未读, 下载浏览全部
2023年 NO C复 赛-P yth o n初 中组 1. 出 租 时间限制:1s 内 存限制:128m b ( 注:in p ut()括 号中不允许添加任何提示语) 根据乘坐出租 出租 请补全下 (1) 程序开始运 (2) 根据规则计算并输出乘坐出租 d = int (input ()) if __________: cost = d * 2 __________ cost = __________ else : cost = __________ print ('%.1f' % cost) 参 考代码: d = int (input ()) if d <= 10 : cost = d * 2 elif d <= 20 : cost = 10 * 2 + (d - 10 ) * 1.5 else : cost = 10 * 2 + 10 * 1.5 + (d - 20 ) print ('%.1f' % cost) 2 . 和 的结果数 单价 第 10公 2元 /公 第 1 1- 20公 1.5 元 /公 第 三阶梯 21公 1元 /公 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 时间限制:1s 内 存限制:128m b ( 注:in p ut()括 号中不允许添加任何提示语) 请补全下 (1) 输 (2) 从这n个 数中任选两个,计算并输出任 意两个数的和共有多少种不同结果。 例如: 输 (3+ 6) 、10( 4+ 6) ,因此,输出结果应为5。 ls = [ int (i) for i in input ().split()] results = [] for i in range (_______): for j in range (_______): s = ls[i] + ls[j] if s not in results: _____________ print (len (results)) 参 考代码: ls = [ int (i) for i in input ().split()] results = [] for i in range (0, len (ls) - 1): for j in range (i + 1, len (ls)): s = ls[i] + ls[j] if s not in results: results.append(s) print (len (results)) 3 . 因 数和个数 时间限制:1s 内 存限制:128m b ( 注:in p ut()括 号中不允许添加任何提示语) 把 和为1 + 2 + 3 + 6 = 1 2。 请 编写 出这些正整数。 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 输 输 输出描述: 第 如果存在,则第 输 12 输 出样例1: 2 6 1 1 样 例说明1: 因 数和为12的 正整数有2个 ,分别是6和 11 输 1 0 输 出样例2: 0 样 例说明2: 因 数和为10的 正整数不存在,所以仅输出0 参 考代码: n = int (input ()) def add (n): if n == 1: return 1     s = 0     for i in range (1, n):         if i ** 2 > n:             break         if n % i == 0:             s += i + n // i         if i ** 2 == n:                 return s cnt = 0 ls = [] for i in range (1, n + 1):     if add(i) == n:         cnt += 1         ls.append(i) print (cnt)  for i in ls:     print (i, end = ' ' ) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 4. 单 词变复数 时间限制:1s 内 存限制:128m b ( 注:in p ut()括 号中不允许添加任何提示语) 英语单词在变成复数形式时,有以下 (1) 常规情况下结尾直接加s; ( 2) 以s、 sh 、 ch 、 x结 尾的单词,加es; ( 3) 以辅 (注:英 请编写 变成复数形式。 输 输 输出描述: 输出这组单词按以上规则变成的复数形式,单词之间以空格隔开 输 te a ch er b ox b utte r 输 出样例: te a ch ers b oxe s b utte r 参 考代码: lsw = input ().split() def plural (word ):     if word[- 1] in [ 's' , 'x' ] or word[- 2:] in [ 'sh' , 'ch' ]:         return word + 'es'     elif word[- 1] == 'y' and word[- 2] not in [ 'a' , 'e' , 'i' , 'o' , 'u' ]:         return word[:- 1] + 'ies'     else :         return word + 's' for w in lsw:     print (plural(w), end= ' ' ) 5 . 啤 酒兑换 时间限制:1s 内 存限制:128m b ( 注:in p ut()括 号中不允许添加任何提示语) 某啤酒品牌正在举办 换 1 2 3 4 5 6 7 8 9 10 请编写 酒,并将这个结果输出。 输 输 输出描述: 输出 输 10 输 出样例: 19 参 考代码: n = int (input ()) total = n bottles = n caps = n while bottles >= 3 or caps >= 5: bottles_t = bottles // 3 caps_t = caps // 5 total += bottles_t + caps_t bottles = bottles - bottles_t * 3 + bottles_t + caps_t caps = caps - caps_t * 5 + bottles_t + caps_t print (total) 6 . 反 转递增串 时间限制:1s 内 存限制:128m b ( 注:in p ut()括 号中不允许添加任何提示语) 编写 例如,正整数12387645包 含两个递增数字 83217654。 输 输 输 出描述: 输出 输 12387645 输 出样例1: 83217654 1 2 3 4 5 6 7 8 9 10 11 输 87654321 输 出样例2: 87654321 参 考代码: n = input () result = '' i = 0 while i < len (n): j = i +
2023年NOC复赛-Python初中组真题
下载提示

下载及版权说明:6547网文库内容来自网络及各平台公开内容(属于用户上传,不保证正确性,只做参考),旨在帮助同学们学习少儿编程相关知识及内容,仅限内部学习及使用,以分享为主,下载本文档之后请合法使用相关、真题、素材、课件、教程等内容,若内容存在侵权,请进行 举报 及查看 免责声明