PYTHON PROJECT
**RANDOM STORY GENERATOR BY
PYTHON**
1..Project:
import random
when=["A few year ago",'yestreday','last
night','on 16 july']
who=['a rabbit','an elephant','a mouse','a
turtle','a cat']
name=['sharad','sanjay','dhanraj','gaurav','shubh
am']
residence=['india','germany','france','canada','en
gland']
went=['cinema','university','seminar','school','hot
el']
happened=['made a lot of friends','eats a
pizza','found a key','wrote a book','solved a
mistery']
print(random.choice(when)
+','+random.choice(when)+','+
random.choice(who)+
' named '+ random.choice(name)+' that lived
in '+random.choice(residence)
+' went to the\t'+random.choice(went)+' and
'+random.choice(happened))
Output:
on 16 july,yestreday,a rabbit named shubham that lived in
france went to the hotel and made a lot of friends
** DIGITAL CLOCK BY PYTHON
2..Project:
from tkinter import Label,Tk
import time
app_window=Tk()
app_window.title("Digital clock by shruti
belekar")
app_window.geometry("420x150")
app_window.resizable(1,1)
text_font=("Bouder",70,'bold')
background="#f2bc07"
foreground="#363634"
border_width=25
label=Label(app_window,font=text_font,bg=back
ground,fg=foreground,bd=border_width)
label.grid(row=0,column=1)
def digital_clock():
time_live=time.strftime("%H:%M:%S")
label.config(text=time_live)
label.after(200,digital_clock)
digital_clock()
app_window.mainloop()
Output:
***Email VALIDATION IN PYTHON***
(using string functions)
3..Project:
email=input("enter your email: ")
k,j,d=0,0,0
if len(email)>=6:
if email[0].isalpha():
if("@" in email) and
(email.count("@")==1):
if (email[-4]==".")^(email[-3]=="."):
for i in email:
if i==i.isspace():
k=1
elif i.isalpha():
if i==i.upper():
j=1
elif i.isdigit():
continue
elif i=="_" or i=="." or i=="@":
continue
else:
d=1
if k==1 or j==1 or d==1:
print("Wrong email 5")
else:
print("Right email ")
else:
print("Wrong email 4")
else:
print("Wrong email 3")
else:
print("Wrong email 2")
else:
print("Wrong email 1")
Output:
enter your email: [email protected]
Right email
enter your email: shruti2 @gmail.com
Wrong email 2
***Email VALIDATION IN PYTHON***
(using RegEx)
4..Project:
Condition:
# a-z [email protected]
# 0-9
# . _time 1
# @ time 1
# . 2,3
import re
email_condition="^[a-z]+[\._]?[a-z 0-9]+
[@]\w+[.]\w{2,3}$"
user_email=input(' Enter your Email : ')
if re.search(email_condition,user_email):
print(" Right Email ")
else:
print(" Wrong Email ")
Output:
Enter your Email : [email protected]
Right Email
***SIMPLE CALCULATOR USING PYTHON***
5..Project:
print('''
+ADD
-SUBTRACT
*MULTIPLICTION
/DIVISION ''')
num1=int(input("enter number1: "))
num2=int(input("enter number2: "))
opr=input("enter the opr....")
if opr=="+":
print(num1+num2)
elif opr=="-":
print(num1-num2)
elif opr=="*":
print(num1*num2)
elif opr=="/":
print(num1/num2)
else:
print("invalid opr....")
Output:
+ADD
-SUBTRACT
*MULTIPLICTION
/DIVISION
enter number1: 2
enter number2: 4
enter the opr....+
6
Other Method:
print('''
+ADD
-SUBTRACT
*MULTIPLICTION
/DIVISION ''')
num1=int(input("enter number1: "))
num2=int(input("enter number2: "))
opr=input("enter the opr....")
if opr!="+" and opr!="-"and opr!="*"and
opr!="/":
print("invalid opr....")
Output:
+ADD
-SUBTRACT
*MULTIPLICTION
/DIVISION
enter number1: 2
enter number2: 4
enter the opr....+
6
*** SIMPLE QR Code Generetor In
PYTHON***
6..Project:
import qrcode as qr
img=qr.make("https://pixabay.com/images/
search/flowers/")
img.save("flower_img.png")
Output:
*** COLOURFULL QR Code Generetor In
PYTHON***
7..Project:
import qrcode
from PTL import image
qr=qrcode.QRCode(Version=1
error_correction=qrcode,ERROR_CORRECT_
H,box_size,border=4)
qr.add_data("https://
www.wscubetech.com/")
qr.make(fit=True)
img=qr.make_make_image(fill_color="red",
black_color="blue")
img.save("wscube_web.png")
Output:
***CREATE CHESS BOARD WITH
PYTHON***
8..Project:
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import LogNorm
dx,dy=0.015,0.05
x=np.arange(-0.4,4.0,dx)
y=np.arange(-0.4,4.0,dy)
X,Y=np.meshgrid(x,y)
extent=np.min(x),np.max(x),np.min(y),np.max(y)
z1=np.add.outer(range(8),range(8))%2
plt.imshow(z1,cmap="binary_r",interpolation="n
earest",extent=extent)
def chess(x,y):
return(1 -x/2+x**5+y**6)*np.exp(-
(x**2+y**2))
z2=chess(X,Y)
plt.imshow(z2,alpha=0.7,interpolation="bilinear",
extent=extent)
plt.title("chess board with python by shruti
belekar")
plt.show()
Output:
***CREATE EMAIL SLICER WITH USING
PYTHON***
9..Project:
email=input("please enter your email: ").strip()
username=email[:email.index("@")]
domain_name = email[email.index("@")+1:]
format_=(f"your username is '{username}' and
your domain s '{domain_name}'")
print (format_)
Output:
please enter your email:
[email protected]
your username is 'shrutibelekar0' and your
domain s 'gmail.com'
*** TO CHECK A NUMBER IS EVEN OR
ODD***
10..Project:
shruti=int(input("enter a number: "))
if (shruti%2)==0:
print("{0} is a even number".format(shruti))
else:
print("{0} is a odd number".format(shruti))
Output:
enter a number: 78
78 is a even number
*** PRINT COLORED CODE WITH
PYTHON***
11..Project:
import colorama
from colorama import Fore ,Back,Style
colorama.init (autoreset=True)
print(Fore.BLUE+Back.YELLOW+"HI,My name is shruti
belekar."+Fore.YELLOW+Back.BLUE+"I Am your python
Instructor")
print(Back.CYAN+"Hi,Again Myself shruti belekar
")
print(Fore.RED+Back.GREEN+"Hi,shruti belekar is
your programming instructor")
Output:
***ADD TWO MATRIX***
12.1..Project:
x=[[12,7,3],[4,5,6],[7,8,9]]
y=[[5,8,1],[6,7,3],[4,5,9]]
result=[[0,0,0],[0,0,0],[0,0,0]]
for i in range(len(x)):
for j in range(len(x[0])):
result[i][j]=x[i][j]+y[i][j]
for r in result:
print(r)
Output:
12.1..Project:
***addition of matrix by nested list
comprehension***
x=[[12,7,3],[4,5,6],[7,8,9]]
y=[[5,8,1],[6,7,3],[4,5,9]]
result=[x[i][j]+y[i][j] for j in range(len(x[0]))
for
i in range(len(x))]
for r in result:
print(r)
Output:
***Check Number Is Positive or
Negative***
13.1..Project:
shruti=float(input("enter a number"))
if shruti>0:
print("positive number")
elif shruti==0:
print("Zero")
else:
print("negative number")
Output:
enter a number-3
negative number
***Using Nested If***
13.2..Project:
shruti=float(input("enter a number"))
if shruti>0:
if shruti==0:
print("zero")
else:
print("positive number")
else:
print("negative number")
Output:
***Create A Countdown Timer***
14..Project:
import time
def countdown(time_sec):
while time_sec:
mins,secs=divmod(time_sec,60)
timeformat='{:02d}:
{:02d}'.format(mins,secs)
print(timeformat,end="\r")
time.sleep(1)
time_sec-=1
print("stop")
countdown(10)
Output:
***EXTRACT EXTENSION FROM FILE
NAME***
15..Project:
import os
sharad=os.path.splitext('img1.jpeg')
print(sharad)
print(sharad[1])
Output:
***FIND THE LARGEST AMONG THREE
NUMBERS***
16..Project:
sharad1=float(input("enter the first number:"))
sharad2=float(input("enter the second
number:"))
sharad3=float(input("enter the third number:"))
if(sharad1>=sharad2)and(sharad1>=sharad3):
largest=sharad1
elif(sharad2>=sharad1)and(sharad2>=sharad3):
largest=sharad2
else:
largest=sharad3
print("the largest Number is",largest)
Output:
enter the first number:2
enter the second number:78
enter the third number:90
the largest Number is 90.0
***FIND SIZE OF A IMAGE***
17..Project:
def jpeg_res(filename):
with open (filename,'rb')as img_file:
img_file.seek(163)
a=img_file.read(2)
height=(a[0]<<8)+a[1]
a=img_file.read(2)
width=(a[0]<<8)+a[1]
print("The resolution of the image
is",width,"X",height)
jpeg_res("img1.jpeg")
Output:
The resolution of image is 514x258
***PROGRAM TO GENERATE RANDOM
PASSWORD***
18..Project:
import random
sharadlen=int(input("please enter the length of
password to be generated: "))
sharad="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNO
PQRSTUVWXYZ1234567890!@#$%&*?"
password="
".join(random.sample(sharad,sharadlen))
print(password)
Output:
***GETLINE COUNT OF FILE***
19..Project:
def file_len(fname):
with open (fname) as f:
for i,j in enumerate(f):
pass
return i+1
print(file_len('count.txt'))
Output: 36
***PYTHON PROGRAM TO MERGE TWO
DICTIONARIES***
20.1..Project:
dict_1={1:'a',2:'b'}
dict_2={2:'c',4:'d'}
print(dict_1|dict_2)
Output:
20.2..Project:
dict_1={1:'a',2:'b'}
dict_2={2:'c',4:'d'}
dict_3=dict_2.copy()
dict_3.update(dict_1)
print(dict_3)
Output:
***PYTHON PROGRAM TO REVERSE A
NUMBER***
21.1..Project:
shruti=1234
reverse_shruti=0
while shruti!=0:
digit=shruti%10
reverse_shruti=reverse_shruti*10+digit
shruti//=10
print("Reversed number is: "+str(reverse_shruti))
Output:
21.2..Project:
# by slicing
shruti=123456
print(str(shruti)[::-1])
Output:
***PYTHON PROGRAM TO SORT WORDS IN
ALPHABETIC ORDER***
22..Project:
My_str="hello my full name is shruti belekar"
My_str=input("enter the string: ")
words=[word.lower()for word in My_str.split()]
words.sort()
print("The sorted words are: ")
for i in words:
print(i)
Output:
PROJECT THAT DOESN’T
RUN
***SPELLING CHECKER APP USING
PYTHON***
23..Project:
from textblob import Textblob
from tkinter import*
def correct_spelling():
get_data=enter1.get()
corr=TextBlob(get_data)
data=corr.correct()
enter2.delete(0,END)
enter2.insert(0,data)
def main_window():
global enter1,enter2
win=Tk()
win.geometry("500x370")
win.resizable(False,False)
win.config(bg="Blue")
win.title("wscube Tech")
label1=Label(win,text="Incorrect
spelling",font=("Time New
Roman",25,"bold"),bg="Blue",fg="White")
label1.place(x=100,y=20,height=50,width=300)
enter1=Entry(win,font=("Time new
Roman",20))
enter1.place(x=100,y=140,height=50,width=40
0)
label2=Label(win,text="correct
spelling",font=("Time New
Roman",25,"bold"),bg="Blue",fg="White")
label2.place(x=100,y=20,height=50,width=300)
enter1=Entry(win,font=("Time new
Roman",20))
enter1.place(x=50,y=200,height=50,width=400)
Button=Button(win,text="Done",font=("Time
new Roman",25,"bold"),bg="yellow")
Button.place(x=150,y=280,height=50,width=20
0)
win.mainloop()
***Create calculator by using gui***
24..Project:
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.label import Label
class shrutiapp(App):
def build(self):
root_widget=BoxLayout(orientation='vertical')
output_label=Label(size_hint_y=0.75,font_size=50)
button_symbols=('1','2','3','+'
'4','5','6','-'
'7','8','9','.'
'0','*','/','=')
button_grid=Gridlayout(cols=4,size_hint_y=2)
for symbol in button_symbols:
button_grid.add_widget(Button(text=symbol))
clear_button=Button(text='clear',size_hint_y=None,Hei
ght=100)
def print_button_text(instance):
output_label.text+=instance.text
for button in button_grid.children[1:]:
button.bind(on_press=print_button_text)
def resize_label_text(label,new_height):
label.fontsize=0.5*label.height
output_label.bind(height=resize_label_text)
def evaluate_result(instance):
try:
output_label.text=str(eval(output_label.text))
except syntaxError:
output_label.text='python syntax Error'
button_grid.children[0].bind(on_press=evaluate_result)
def clear_label(instance):
output_label.text=" "
clear_button.bind(on_press=clear_label)
root_widget.add_widget(output_label)
root_widget.add_widget(button_label)
root_widget.add_widget(clear_label)
return root_widget
shrutiapp().run()
***Otp verification by python***
25..Project:
import OS
import math
import random
import smtplib
digits="0123456789"
OTP=""
for i in range(6):
OTP+=digits[math.floor(random.random()*10)]
otp=OTP+"is your OTP"
msg=otp
"""this link is for signing the google App
password,please follow the instruction:
https://support.google.com/accounts/answer/185
833?hl=en"""
s=smtplib.SMTP('smtp.gmail.com',587)
s.starttls()
s.login("shrutibelekar","****")
emailid=input("please enter your email: ")
s.sendmail('&&&&&&&&&&&',emailid,msg)
a=input("please enter your OTP>>: ")
if a==OTP:
print("yes,your OTP is verified")
else:
print("P")
***Get live stock data using python***
26..Project:
import pandas as pd
import yfinance as yf
import datetime
from datetime import date ,timedelta
today = date.today()
d1=today=strftime("%Y-%m-%d")
end_date=d1
d2=date.today()-timedelta(days=360)
d2.strftime("%Y-%m-%d")
start_date=d2
data=yf.download('AAPL',start=start_data,end=end_date,progress=Fals
e)
data["Date"]=data.index
data=data[["Date","open","high","Low","Close","Adj close","volume"]]
data.reset_index(drop=True,inplace=True)
print(data.head)
***program to check the file***
27..Project:
import os
sharad= os.stat('count.txt')
print(sharad.st_size)
from pathlib import Path
sharad=Path('count.txt')
print(sharad().stat().st_size)
***python program to extract extension
from file name***
28..Project:
h=hashlib.
with open(filename,'rb') as file:
chunk=0
while chunk!=b' ':
chunk=file.read(1024)
h.update(chunk)
return h.hexdigest()
message=hash_file("img1.jpeg")
print(message)
***find size of a image***
29..Project:
def jpeg_res(filename):
with open (filename,'rb')as img_file:
img_file.seek(163)
a=img_file.read(2)
height=(a[0]<<8)+a[1]
a=img_file.read(2)
width=(a[0]<<8)+a[1]
print("The resolution of the image
is",width,"X",height)
jpeg_res("img1.jpeg")
*** Web scraper with python
datacode***
30..Project:
import urllib.request
from bs4 import BeautifulSoup
class scraper:
def_init_(self,site):
self.site=site
def scrape(self):
sharad=urllib.request.urlopen(self.site)
html=sharad.read()
parser="html.parser"
sp=BeautifulSoup(html,parser)
for tag in sp.find_all("a"):
url=tag.get("href")
if url is None:
continue
if "articles" in url:
print("\n"+url)
news="https://news.google.com/"
scraper(news).scrape()