5 Python Programme Ideas for a newbie Python Learner
5 Python mini projects that everyone should build (with codes)
Hi there, I am Dexter
We are in 2021. we all know that it industry is growing day by day. if you see from 2013 to 2019 the growth of python in the industry is around 40% and it is said that it will grow up to 20% more in the next few years. the increased rate of python developers is increased by 30% in the past few years.so there is no better time for learning python and to learn python there is no better way than doing projects.
In this blog, we will create 10 python mini-projects.
- Dice roll simulator
- Guess the number game
- Random password generator
- Sending emails using python
- Medium Article Reader
2. Guess the number game
3. Random password generator
To create a program that takes a number and generate a random password length of that number.
Topics: random module, joining strings, taking input
Hint: Create a string with all characters, then take random characters from it and concatenate each char to make a big string.
GIVE A TRY ON YOUR OWN
import random
passlen = int(input("enter the length of password"))
s="abcdefghijklmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()?"
p = "".join(random.sample(s,passlen ))
print (p)
4. Sending emails using python
To create a python script that can send emails
Topics: import packages, SMTP lib, sending a request to the server
GIVE A TRY ON YOUR OWN
import smtplib from email.message import EmailMessageemail = EmailMessage() ## Creating a object for EmailMessageemail['from'] = 'xyz name' ## Person who is sendingemail['to'] = 'xyz id' ## Whom we are sendingemail['subject'] = 'xyz subject' ## Subject of emailemail.set_content("Xyz content of email") ## content of emailwith smtlib.SMTP(host='smtp.gmail.com',port=587)as smtp:
## sending request to server
smtp.ehlo() ## server objectsmtp.starttls() ## used to send data between server and clientsmtop.login("email_id","Password") ## login id and password of gmailsmtp.send_message(email) ## Sending emailprint("email send") ## Printing success message
5. Medium Article Reader
The task is to create a script that can read articles from a link.
Topics: web scraping, text to speech
Hint: Take the URL of the article as input, scrape the text from the link and then pass it to text to speech.
GIVE A TRY ON YOUR OWN
import pyttsx3
import requests
from bs4 import BeautifulSoup
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[0].id)def speak(audio):
engine.say(audio)
engine.runAndWait()text = str(input("Paste article\n"))
res = requests.get(text)
soup = BeautifulSoup(res.text,'html.parser')
articles = []
for i in range(len(soup.select('.p'))):
article = soup.select('.p')[i].getText().strip()
articles.append(article)
text = " ".join(articles)
speak(text)# engine.save_to_file(text, 'test.mp3') ## If you want to save the speech as a audio fileengine.runAndWait()
Comments
Post a Comment