python 编程刷题_一起刷题吧 | 100+Python编程题带你快速上手(附答案)
来源:Python大本营
本文约1000字,建议阅读5分钟。
100+编程练习帮大家轻松学习Python,春节也要抓紧学习哟~
春节马上就要到了,怎么能让自己在假期里不掉队?今天,给大家准备一个项目: 100+ 编程练习,这些题如果能坚持每天至少完成一道,一定可以帮大家轻松 get Python 的编程技能。目前,这个项目已经获得了 2924 Stars,2468 Forks。
首先,这 100+ 练习题根据难易程度分为三个等级:Level 1、2 和 3。下面对如何定义这三个 Level 进行了说明,大家可以结合自身的学习能力和实践经验进行选择。
Level 1:初级。刚入门 Python 或者正在学一些基础课程的同学们。通常包含 1 到 2 个类或函数的问题都可以解决,甚至答案都可能在一些教材中就能找到。
Level 2:中级。已经系统学习过 Python,并且已经有一定的编程背景的同学们,可以解决包含 3 个及以上类或函数的问题,不过这些答案就在教材找不到了。
Level 3:高级:可以用 Python 中非常丰富的各种库、标准包或更高级的技术,结合数据结构和算法,来解决复杂的问题。
其次,每题都有问题描述、提示和解决方案。大家一定要先独立完成,然后再看参考答案哦~
前 25 题中,Q1~5、22~25 都是 Level 1 的难度,Q6~17 为 Level 2,Q18~22 为 Level 3。大家正好利用这五道题学习、巩固一下基础,然后就开始准备挑战自己吧!
前五道题
下面先给出前五道题,其他的题目大家可以在 Github 上看到~Question 1
Level 1
Question:
Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5,
between 2000 and 3200 (both included).
The numbers obtained should be printed in a comma-separated sequence on a single line.
Hints:
Consider use range(#begin, #end) methodQuestion 2
Level 1
Question:
Write a program which can compute the factorial of a given numbers.
The results should be printed in a comma-separated sequence on a single line.
Suppose the following input is supplied to the program:
8
Then, the output should be:
40320
Hints:
In case of input data being supplied to the question, it should be assumed to be a console input.Question 3
Level 1
Question:
With a given integral number n, write a program to generate a dictionary that contains (i, i*i) such that is an integral number between 1 and n (both included). and then the program should print the dictionary.
Suppose the following input is supplied to the program:
8
Then, the output should be:
{1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64}
Hints:
In case of input data being supplied to the question, it should be assumed to be a console input.
Consider use dict()Question 4
Level 1
Question:
Write a program which accepts a sequence of comma-separated numbers from console and generate a list and a tuple which contains every number.
Suppose the following input is supplied to the program:
34,67,55,33,12,98
Then, the output should be:
['34', '67', '55', '33', '12', '98']
('34', '67', '55', '33', '12', '98')
Hints:
In case of input data being supplied to the question, it should be assumed to be a console input.
tuple() method can convert list to tuple
答案要点Question 5
Level 1
Question:
Define a class which has at least two methods:
getString: to get a string from console input
printString: to print the string in upper case.
Also please include simple test function to test the class methods.
Hints:*Solution 1*
l=[]
for i in range(2000, 3201):
if (i%7==0) and (i%5!=0):
l.append(str(i))
print ','.join(l)
___________________________________
*Solution 2*
def fact(x):
if x == 0:
return 1
return x * fact(x - 1)
x=int(raw_input())
print fact(x)
___________________________________
*Solution 3*
n=int(raw_input())
d=dict()
for i in range(1,n+1):
d[i]=i*i
print d
___________________________________
*Solution 4*
values=raw_input()
l=values.split(",")
t=tuple(l)
print l
print t
___________________________________
*Solution 5*
class InputOutString(object):
def __init__(self):
self.s = ""
def getString(self):
self.s = raw_input()
def printString(self):
print self.s.upper()
strObj = InputOutString()
strObj.getString()
strObj.printString()Use __init__ method to construct some parameters
更多题目可以查阅以下Github地址:作者:zhiwehu
https://github.com/zhiwehu/Python-programming-exercises/blob/master/100%2B%20Python%20challenging%20programming%20exercises.txt
python 编程刷题_一起刷题吧 | 100+Python编程题带你快速上手(附答案)相关推荐
- c++刷题_今日刷题(5)
微信小程序可以刷题咯,购买系统班同学可以在学员群中打卡小程序刷题,错过可以在公众号补充练习,但公众号不对答案进行解析哟~一起刷题嗨起来~ 刷题知识模块与系统班授课进程匹配温馨提示:公众号刷题并非每天都 ...
- 在哪里刷题_击穿刷题马太效应,用20%的时间,快速刷出80%的成绩!高三冲刺必看!...
刷题,作为巩固知识点的经典操作,也是提分的重要手段.同样是刷题,有人突飞猛进,有人却淹没题海. 如何通过刷题提升学习效率和考试成绩?怎样打破题海恐惧?善用刷题实现逆袭? 日刷5套数学卷,考前生病耽误一 ...
- python异常处理语句编程题_一篇文章让你掌握Python异常处理所有知识点,记得收藏...
异常处理在任何一门编程语言里都是值得关注的一个话题,良好的异常处理可以让你的程序更加健壮,清晰的错误信息更能帮助你快速修复问题.在Python中,和不分高级语言一样,使用了try/except/fin ...
- javascript编程题_如何开始使用JavaScript进行竞争性编程
javascript编程题 by Priyabrata Biswas 通过Priyabrata Biswas 如何开始使用JavaScript进行竞争性编程 (How to get started w ...
- java自考真题_自考04747JAVA语言程序设计(一)历年真题试卷下载
在与考生的交流过程中,我们发现考生对于自考真题的需求非常大,而网上内容参差不齐,有些缺字漏字,有些科目真题找不全,希赛学历中心为方便各位自考生更快更好地找到各科目的真题内容,特别整理了各科目真题资料供 ...
- 少儿学python真的有用吗_如何看待海淀妈妈们认为Python是儿童才学的低端编程?...
海淀妈妈没说错啊~ 对于她们,python确实是儿童才学的低端编程. 儿童学编程,最重要的是易上手,当然要用代码看起来更简单的动态语言. 主流的动态语言里,ruby太骚,js太贱,php太浪,只有py ...
- android 如何刷机,安卓怎么刷机_安卓刷机图解_刷机大师教程
刷机大师是傻瓜模式的刷机软件,只要按照简单的几个步骤操作,是很简单的,以下是刷机教程,仅针对刷机大师的使用方法.双清是卡刷的步骤,刷机大师是一键刷机,类似线刷,是不用双清的. ⒈)首先下载" ...
- oppok3如何刷机_[oppok3刷机教程]oppok3怎么刷机
有很多朋友都不会刷机,还要去花钱到外面刷机,其实刷机并没有大家想象得那么难,所以今天给大家带来一个详细的OPPO K1刷机教程,赶紧试试吧. oppo k3怎么刷机 一.刷机相关术语介绍 1.RE模式 ...
- 小程序商店刷榜_机刷8毛,人刷2块2,好评app都是刷出来的?苹果:刷榜app将从应用商店移除...
(原标题:机刷8毛,人刷2块2,好评app都是刷出来的?苹果:刷榜app将从应用商店移除) 随着智能手机的普及,手机上的应用软件与我们的生活越来越密不可分.当你在手机上下载应用软件的时候,你会去看这个 ...
- 安卓系统刷机怎么刷机_手机刷机怎么刷
有人说玩安卓机不刷机就体验不到真正的乐趣,那么手机怎么刷机呢?下面小编会介绍方法给想刷机的朋友,一起来看看吧. 手机刷机怎么刷 步骤1:手机安装一款刷机软件[卓大师],很多刷机软件都有一键ROOT的功 ...
最新文章
- linux下QT Creator常见错误及解决办法
- mysql 2014_mysql错误之2014
- linux闲话FHS标准下linux目录结构
- ExecutorService- Future - Java多线程编程
- 添加three20模板的方法
- Node.js笔记-使用socket.io构建websocket聊天室
- 优先级调度算法实现_React17新特性:启发式更新算法
- 【github系列】github上传空目录
- Linux-目录和文件管理(二)
- 作业四: 结对编程项目---四则运算
- SharePoint【学习笔记】-- SPWeb.EnsureUser()注意AllowUnsafeUpdates=true
- 免费报名 | DataFunCon:自然语言处理论坛
- Scrapy爬取QQ音乐、评论、下载、歌曲、歌词
- ANSYS——模态分析的理论基础
- 视频教程:小型登陆系统(完)
- 使用 C# 编程对 RTF 文档进行操作 [转载]
- Qt-命令行更新翻译.ts文件
- UTC时间转北京时间
- 高通ims架构android,深度揭密高通4/5G移动基带消息系统和状态机
- 3des java ecb_3DES_ECB_加密解密
热门文章
- kibana数据导入导出_MySQL数据库批量导出和导入查询数据
- linux arm. 快速启动,教你如何快速启动Linux 系统
- php5.4全局变量,PHP 5 全局变量 - 超全局变量
- n平方的求和公式_高中数学:数列求和及数列的综合应用,掌握常见模型
- 计算机硬件基础英语ppt,计算机硬件技术基础,computer hardware technology elements,音标,读音,翻译,英文例句,英语词典...
- python list remove_python list有关remove的问题
- linux和python哪个工资高,关于树莓派:用它来学习Linux及Python真的高效?
- c# forbidden.html,c# - google+ api error forbidden 403 - Stack Overflow
- mysql 报错跳过_mysql跳过主从同步错误
- laravel encryptstring加密使用方法_磁盘加密怎么取消 重装系统后加密磁盘无法使用的解决方法...