初学者python项目_面向初学者的五个Python项目

初学者python项目

Learning a new programming language is both a challenging and exciting part which we always experience. For me, that language has been Python, As coders, we all know the best part of getting towards the path of perfection in any programming language is by building projects. With that in mind, let’s discuss a few python mini-projects which you can implement and polish your skills in python.

大号赢得新的编程语言既是一个具有挑战性和令人兴奋的部分,我们经常遇到。 对我而言,该语言一直是Python。作为编码人员,我们都知道,在任何编程语言中通向完美之路的最好部分就是构建项目。 考虑到这一点,让我们讨论一些python小型项目,您可以在python中实现和完善您的技能。

I would recommend not referring to the code below at the beginning. First, read the project instructions and try implementing them on your own. That will be the most challenging part—seeing if you can do it based on your current knowledge alone. If you get stuck feel free to get back and check the code out.

我建议一开始不要参考下面的代码。 首先,请阅读项目说明并尝试自己实施。 那将是最具挑战性的部分-仅根据当前的知识来看看是否可以做到。 如果您卡住了,请随时回来查看代码。

If you get stuck with any of the mentioned projects below, feel free to contact me and I’ll try responding as soon as possible. That, or just look online—remember: Google is your best friend.

如果您陷于下面提到的任何项目,请随时与我联系,我会尽快答复。 那,或者只是上网看看,请记住:Google是您最好的朋友。

Let’s get started.

让我们开始吧。

1.密码生成器 (1. Password Generator)

Write a program that generates a random password for the user. If you want to make it better, you can add features by asking users who long they want their password to be, how many letters or numbers do they want. Have a mix of Upper or lower case and symbols.

编写一个为用户生成随机密码的程序。 如果您想使它更好,则可以通过询问用户想要密码多长时间,想要多少个字母或数字来添加功能。 混合使用大小写和符号。

You can even create a GUI based password generator if you are aware with tkinter library or even a normal password generator would also be perfectly fine.

如果您了解tkinter库,甚至可以创建基于GUI的密码生成器,甚至普通的密码生成器也可以。

Image for post

Using Tkinter → It is the standard GUI library for Python. It generates a random password in the form of a GUI based Application. we can implement the code as shown below:

使用Tkinter →这是Python的标准GUI库。 它以基于GUI的应用程序的形式生成随机密码。 我们可以实现如下代码:

Image for post

2.基本计算器 (2. Basic Calculator)

To make simple calculator in python to perform basic mathematical operations such as addition, subtraction, multiplication, division of two numbers entered by the user. To make a calculator in python, first provide 5 options to the user, the fifth option for exit. After providing all the five options to the user, ask the user to enter his/her choice, and perform the desired operation as shown in the program given below.

在python中使用简单的计算器执行基本的数学运算,例如用户输入的两个数字的加,减,乘,除。 要使用python创建计算器,请首先为用户提供5个选项,第5个退出选项。 在向用户提供所有五个选项之后,请用户输入他/她的选择,然后执行所需的操作,如以下程序所示。

Image for post

3,猜数字 (3.Number Guessing)

This is a simple yet exciting idea. You can even call it a mini-game. Make a program in which the computer randomly chooses a number between 1 to 10, 1 to 100, or any range. Then give users a hint to guess the number. Every time the user guesses wrong, he gets another clue, and his score gets reduced. The clue can be multiples, divisible, greater or smaller, or a combination of all.

这是一个简单但令人兴奋的想法。 您甚至可以称其为迷你游戏。 制作一个程序,让计算机在其中随机选择1到10、1到100或任意范围内的数字。 然后给用户提示猜测数字。 每次用户猜错了,他都会得到另一个线索,分数也会降低。 线索可以是多个,可整除,更大或更小或所有的组合。

You will also need functions to compare the inputted number with the guessed number, to compute the difference between the two, and to check whether an actual number was inputted or not.

您还需要一些函数,将输入的数字与猜测的数字进行比较,计算两者之间的差,并检查是否输入了实际数字。

Image for post

4,二进制搜索算法 (4.Binary search algorithm)

Create a list of random numbers between 0 to 100 in a list and a assign a parameter(n) which is the number to be found from the list of numbers. Using loops

在列表中创建一个介于0到100之间的随机数列表,并分配一个参数(n),该参数是要从数字列表中找到的数字。 使用循环

The binary search algorithm works by splitting a list into two, and then checks on which half the item being searched for can’t lie. The process of splitting is repeated on the half where the item can be until it’s found, or you have an empty list

二进制搜索算法的工作原理是将一个列表分成两部分,然后检查要搜索的项目中哪一半不能撒谎。 拆分过程会在项目可能存在的一半上重复进行,直到找到为止,或者您有一个空列表

Important points

重要事项

  1. List should in ascending order

    清单应按升序排列
  2. first value should be lower bound

    第一个值应该是下界
  3. 3. last value should be as a upper bound

    3.最后一个值应作为上限
  4. mid value = lower + upper / 2

    中值=较低+较高/ 2
Image for post

(Check out my previous story on different types of search algorithms, which also includes a detailed explanation of binary search algorithm. Understanding the basics of algorithms and the related field of data structures is essential for doing serious work in pretty much any branch of computer science.)

(查阅我以前关于不同类型的搜索算法的故事,其中还包括对二进制搜索算法的详细说明。了解算法的基础知识和数据结构的相关领域对于在计算机科学的几乎任何分支中进行认真的工作都是必不可少的)

5.骰子滚动模拟器 (5. Dice Rolling Simulator)

This project involves writing a program that simulates rolling dice. When the program runs, it will randomly choose a number between 1 and 6. The program will print what that number is. It should then ask you if you’d like to roll again. For this project, you’ll need to set the min and max number that your dice can produce. For the average die, that means a minimum of 1 and a maximum of 6. You’ll also want a function that randomly grabs a number within that range and prints it.

该项目涉及编写一个模拟掷骰子的程序。 程序运行时,它将随机选择一个1到6之间的数字。程序将打印该数字。 然后,它将询问您是否要再次滚动。 对于此项目,您需要设置骰子可以产生的最小和最大数目。 对于普通骰子,这意味着最小为1,最大为6。您还需要一个函数,该函数随机获取该范围内的数字并打印出来。

Image for post

最后的想法 (Final thoughts)

The Python projects discussed in this blog should help you kickstart your learning about Python and push you to learn more about Python practically. This will be very handy and helpful when you are trying to consider a problem and providing a solution for that using Python.

在本博客中讨论的Python项目应该可以帮助您开始学习Python,并推动您实际学习更多有关Python的知识。 当您尝试考虑问题并使用Python提供解决方案时,这将非常方便且有用。

If you get stuck somewhere or want me to write more such content on intermediate level projects feel free to contact me, you can contact me by commenting below or through my website link below.

如果您陷于某个地方或希望我在中级项目上写更多这样的内容,请随时与我联系,您可以通过以下评论或通过下面的我的网站链接与我联系。

翻译自: https://medium.com/swlh/five-python-projects-for-beginners-f87dbfe43593

初学者python项目

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值