Skip to content

Commit 8334655

Browse files
Merge branch 'avinashkranjan:master' into master
2 parents 2b21c7d + cbe16aa commit 8334655

File tree

90 files changed

+4978
-52
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+4978
-52
lines changed

Age_Calculator/Age_Calculator.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# importing the date module from the datetime package
2+
from datetime import date
3+
4+
# defining a function calculate the age
5+
def calculate_age(birthday):
6+
7+
# using the today() to retrieve today's date and stored it in a variable
8+
today = date.today()
9+
10+
# a bool representing if today's day, or month precedes the birth day, or month
11+
day_check = ((today.month, today.day) < (birthday.month, birthday.day))
12+
13+
# calculating the difference between the current year and birth year
14+
year_diff = today.year - birthday.year
15+
16+
# The difference in years is not enough.
17+
# We must subtract 0 or 1 based on if today precedes the
18+
# birthday's month/day from the year difference to get it correct.
19+
# we will subtract the 'day_check' boolean from 'year_diff'.
20+
# The boolean value will be converted from True to 1 and False to 0 under the hood.
21+
age_in_years = year_diff - day_check
22+
23+
# calculating the remaining months
24+
remaining_months = abs(today.month - birthday.month)
25+
26+
# calculating the remaining days
27+
remaining_days = abs(today.day - birthday.day)
28+
29+
# printing the age for the users
30+
print("Age:", age_in_years, "Years", remaining_months, "Months and", remaining_days, "days")
31+
32+
# main function
33+
if __name__ == "__main__":
34+
35+
# printing an opening statement
36+
print("Simple Age Calculator")
37+
38+
# asking user to enter birth year, birth month, and birth date
39+
birthYear = int(input("Enter the birth year: "))
40+
birthMonth = int(input("Enter the birth month: "))
41+
birthDay = int(input("Enter the birth day: "))
42+
43+
# converting integer values to date format using the date() method
44+
dateOfBirth = date(birthYear, birthMonth, birthDay)
45+
46+
# calling the function to calculate the age of a person
47+
calculate_age(dateOfBirth)

Age_Calculator/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
**Age_Calculator**
2+
3+
4+
5+
**Step1:**
6+
7+
First of all, we need to import two libraries into our code. The first one is the time and date
8+
9+
**Step2:**
10+
11+
Now, just use Age_Calculator.py code run it on online r any complier
12+
13+
**Step3:**
14+
15+
It will frist your date of birth year!
16+
17+
**Step4:**
18+
19+
Then it will ask your birth month!
20+
21+
**Step5:**
22+
23+
Then it will ask your birth day!
24+
25+
**Step6:**
26+
27+
Finally it will just a date of you enterted and current date and time it will print the the years and months days!
28+
29+
**conclusion:**
30+
31+
It is useful to Calculate birthdays in years!
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## SIGN UP GUI PAGE
2+
3+
To run the code, you need to specify the file paths where the username and password will be stored in a .txt format. Once you have set the file paths correctly, you can simply run the program.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import tkinter as tk
2+
import tkinter.messagebox
3+
from tkinter import PhotoImage
4+
from tkinter import messagebox
5+
from tkinter.font import Font
6+
import customtkinter
7+
from PIL import Image, ImageTk
8+
9+
customtkinter.set_appearance_mode("dark")
10+
11+
def check_credentials(username, password):
12+
# Read the stored usernames and passwords from text files
13+
with open('File Path Where username is stored', 'r') as f_username, open('File Path where password is stored', 'r') as f_password:
14+
stored_usernames = f_username.read().splitlines()
15+
stored_passwords = f_password.read().splitlines()
16+
17+
# Check if the entered credentials match any of the stored values
18+
for stored_username, stored_password in zip(stored_usernames, stored_passwords):
19+
if username == stored_username and password == stored_password:
20+
return True
21+
22+
return False
23+
24+
25+
class Login(customtkinter.CTk):
26+
width = 1240 #helps in image width
27+
height = 1080 #helps in image height
28+
def __init__(self):
29+
super().__init__()
30+
31+
# OPENEING WINDOW SIZE
32+
self.title("Login")
33+
self.geometry(f"{1240}x{720}")
34+
# IMAGE ADDITION IN BACKGROUND
35+
# self.bg_image = customtkinter.CTkImage(Image.open("Image Path"),size=(self.width, self.height))
36+
# self.bg_image_label = customtkinter.CTkLabel(self, image=self.bg_image)
37+
# self.bg_image_label.grid(row=0, column=0)
38+
39+
# LOGIN FRAME INSIDE WINDOW
40+
# TEXT : "Welcome!\nUnified Travelling & Transport System"
41+
self.login_frame = customtkinter.CTkFrame(self, corner_radius=15)
42+
self.login_frame.grid(row=0, column=0, sticky="ns")
43+
self.login_label = customtkinter.CTkLabel(self.login_frame, text="Welcome!\nTo lOIGN pAGE",font=customtkinter.CTkFont(size=24, weight="bold", slant="roman", family="Helvetica"))
44+
self.login_label.grid(row=0, column=0, padx=30, pady=(150, 15))
45+
46+
#TEXT : LOGIN PAGE
47+
self.login_label_2 = customtkinter.CTkLabel(self.login_frame, text="Login Page",font=customtkinter.CTkFont(size=40, weight="bold"))
48+
self.login_label_2.grid(row=1, column=0, padx=30, pady=(50, 15))
49+
50+
#TEXT : USERNAME
51+
self.username_entry = customtkinter.CTkEntry(self.login_frame, width=300, placeholder_text="Username")
52+
self.username_entry.grid(row=2, column=0, padx=30, pady=(15, 15))
53+
54+
#TEXT : PASSWORD
55+
self.password_entry = customtkinter.CTkEntry(self.login_frame, width=300, show="*", placeholder_text="Password")
56+
self.password_entry.grid(row=3, column=0, padx=30, pady=(0, 15))
57+
58+
#TEXT : LOGIN BUTTON TEXT
59+
self.login_button = customtkinter.CTkButton(self.login_frame, text="Login", command=self.login_event, width=200)
60+
self.login_button.grid(row=4, column=0, padx=30, pady=(15, 15))
61+
62+
def login_event(self):
63+
64+
entered_username = self.username_entry.get()
65+
entered_password = self.password_entry.get()
66+
67+
QueryCheckForPassword=sql.Query_LoginCheck(entered_username, entered_password)
68+
69+
if QueryCheckForPassword:
70+
self.destroy()
71+
72+
else:
73+
print("error")
74+
return messagebox.showerror('Error','Incorrect Username or Password')
75+
76+
print("Login pressed - username:", entered_username, "password:",entered_password)
77+
78+
if __name__ == "__main__":
79+
app9 = Login()
80+
app9.mainloop()
Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
11
import plotly.graph_objects as go
22
import numpy as np
33

4-
np.random.seed(42)
4+
def create_line_chart(x_data, y_data):
5+
fig = go.Figure(data=go.Scatter(x=x_data, y=y_data))
56

6-
# declaring size of arr
7-
size = 7
7+
# Modifying the tickangle of the xaxis, and adjusting width and height of the image
8+
fig.layout.template = 'plotly_dark'
9+
fig.update_layout(
10+
title='Line Chart',
11+
xaxis_title='X Axis Title',
12+
yaxis_title='Y Axis Title',
13+
xaxis_tickangle=-45,
14+
autosize=False,
15+
width=600,
16+
height=600,
17+
margin=dict(l=50, r=50, b=100, t=100, pad=4)
18+
)
19+
fig.show()
820

9-
x = np.arange(10)
10-
y = x ** 2
21+
if __name__ == "__main__":
22+
np.random.seed(42)
1123

12-
fig = go.Figure(data=go.Scatter(x=x, y=x**2))
24+
# Generating sample data
25+
x_data = np.arange(10)
26+
y_data = x_data ** 2
1327

14-
# Modifying the tickangle of the xaxis, and adjusting width and height of the image
15-
fig.layout.template = 'plotly_dark'
16-
fig.update_layout(
17-
title='Line Chart',
18-
xaxis_title='X Axis Title',
19-
yaxis_title='Y Axis Title',
20-
xaxis_tickangle=-45,
21-
autosize=False,
22-
width=600,
23-
height=600,
24-
margin=dict(l=50, r=50, b=100, t=100, pad=4)
25-
)
26-
fig.show()
28+
try:
29+
create_line_chart(x_data, y_data)
30+
except Exception as e:
31+
print("An error occurred:", str(e))

Face_Detection_using_openCV/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Face-Detection-using-OpenCV
2+
This program helps to detect any moving objects in the frame which further hepls us to understand if any object is moving out of the frame or not.
3+
4+
# Prerequisites
5+
Any System with a working webcam
6+
Any System having Python version 3 installed
7+
8+
# Dependencies
9+
Installed Pandas module
10+
Installed cv2 module
11+
Imported time module
12+
imported Datetime module

Face_Detection_using_openCV/script.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
2+
import time
3+
from datetime import datetime
4+
5+
import cv2
6+
import pandas
7+
8+
video=cv2.VideoCapture(0)
9+
first_frame=None
10+
status_list=[None,None]
11+
time=[]
12+
df=pandas.DataFrame(columns=["Start","End"])
13+
cnts= [[0,0], [255,0], [255,255], [0,255]]
14+
while True:
15+
check, frame = video.read()
16+
status=0
17+
gray=cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
18+
gray=cv2.GaussianBlur(gray,(21,21),0)
19+
if first_frame is None:
20+
first_frame=gray
21+
continue
22+
delta_frame=cv2.absdiff(first_frame,gray)
23+
thresh_data=cv2.threshold(delta_frame,30,255,cv2.THRESH_BINARY)[1]
24+
thresh_delta=cv2.dilate(thresh_data,None,iterations=5)
25+
(cnts,_) =cv2.findContours(thresh_data.copy(),cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)
26+
for contour in cnts:
27+
if cv2.contourArea(contour)<10000:
28+
continue
29+
status=1
30+
(x,y,w,h)=cv2.boundingRect(contour)
31+
cv2.rectangle(frame,(x,y),(x+w,y+h),(0,255,0),3)
32+
status_list.append(status)
33+
if status_list[-1]==1 and status_list[-2]==0:
34+
time.append(datetime.now())
35+
if status_list[-1]==0 and status_list[-2]==1:
36+
time.append(datetime.now())
37+
cv2.imshow("Capturing", gray)
38+
cv2.imshow("Delta Frame",delta_frame)
39+
cv2.imshow("Threshold Frame",thresh_data)
40+
cv2.imshow("Colour Frame",frame)
41+
42+
43+
key=cv2.waitKey(1)
44+
if key==ord('q'):
45+
if status==1:
46+
time.append(datetime.now())
47+
break
48+
49+
50+
print(time)
51+
for i in range(0,len(time),2):
52+
df=df.append({"Start":time[i],"End":time[i+1]},ignore_index=True)
53+
df.to_csv("Times.csv")
54+
55+
video.release()
56+
cv2.destroyAllWindows
57+

Flipkart_webscraping/Scrap.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import pandas as pd
2+
import requests
3+
from bs4 import BeautifulSoup
4+
5+
Product_name=[]
6+
Prices=[]
7+
Description=[]
8+
Reviews=[]
9+
10+
for i in range(2,43):
11+
#url="https://www.flipkart.com"
12+
url="https://www.flipkart.com/search?q=MOBILE+PHONE+UNDER+50000&otracker=search&otracker1=search&marketplace=FLIPKART&as-show=on&as=off&page="+str(2)
13+
14+
r=requests.get(url)
15+
soup=BeautifulSoup(r.text,"lxml")
16+
17+
box=soup.find("div",class_="_1YokD2 _3Mn1Gg")
18+
names=box.find_all("div",class_="_4rR01T")
19+
20+
#scraping data 1.product name
21+
for i in names:
22+
name=i.text
23+
Product_name.append(name)
24+
25+
#2.prices
26+
prices=box.find_all("div",class_="_30jeq3 _1_WHN1")
27+
for i in prices:
28+
name=i.text
29+
Prices.append(name)
30+
31+
#3.description
32+
desc=box.find_all("ul",class_="_1xgFaf")
33+
for i in desc:
34+
name=i.text
35+
Description.append(name)
36+
37+
#4.reviews
38+
revi=box.find_all("div",class_="_3LWZlK")
39+
for i in revi:
40+
name=i.text
41+
Reviews.append(name)
42+
43+
#data frame
44+
df=pd.DataFrame({"Product Name":Product_name,"Prices":Prices,"Description":Description,"Reviews":Reviews})
45+
#print(df)
46+
47+
#DF TO CSV
48+
df.to_csv("filpkart-Scraping-under-50k.csv")
49+
50+
51+

Flipkart_webscraping/Steps.txt

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
WEB SCRAPING
2+
3+
We are doing web scraping of filpkart with Python, which will let us analyse the data from a specific website and store it in many formats such as CSV, txt, excell, and so on.
4+
this data can use for various reasons like for sentiment analyse and want to know specific review from multiple user.
5+
6+
-<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< STEPS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
7+
8+
STEP 1;
9+
We are request to "flipkart" for scraping the data.
10+
requests.get :- function is use becoz to know the status code. request to flipkart from fetching the data in form of html
11+
response 200:- we can succesfully get the data in form web.
12+
13+
STEP 2:
14+
(i)=know how to deal with multiple pages :
15+
(ii)=format use-LXML = allows for easy handling of XML and HTML files, and can also be used for web scraping.
16+
(iii)=get the html of web in you vs or local so that u can work on it.
17+
(iv)=as their are many pages realted to SINGLE so now fetch data form multiple pages
18+
-try to find ancare tag <a> in the html of page
19+
-not for 2,3 just for NEXT page.
20+
-we have to find a tag of particular tag and for link href and print that.
21+
-in href there is link without the 'https' so to get we just add
22+
cnp="https://www.flipkart.com"+np
23+
24+
(v)=so for web scrap we have to fetch the link of all pages its time taking process so we create a loop for this procces which fetch all link for us.
25+
now we will use for loop to fetch data
26+
for i in range(1(start),10(end))
27+
to move multiple pages we have to use in last of link + [srt(i)]
28+
29+
(vi)=Decide want data want to scrap like:-
30+
-product name ,prize, reveiws ,description.
31+
-create list for every indivdual info.
32+
-Product_name=[]
33+
-Prices=[]
34+
-Description=[]
35+
-Reviews=[]
36+
37+
(vii)=now create a function for each info what u want to fetch and store that data into realted list.
38+
revi=soup.find_all("div",class_="_3LWZlK")
39+
for i in revi:
40+
name=i.text
41+
Reviews.append(name)
42+
print(Reviews)
43+
similarly do for all the list
44+
(viii)=point to remember that we are scraping data form parcticluar box or area so we have to specify that area making variable BOX.
45+
(xi)=now create the datafarme with the help of pandas pf.DATAFRAME({"key":value}) store int the form of key and value.
46+
no remember that we are scraping the data for multiple pages so DON'T FORGET TO RE APPLY THE FOR LOOP AND THE str(i) for multiple pages.
47+
48+
(xii)=last step to convet that data frame into csv file
49+
50+
STEP 3
51+
df.to_csv("filpkart-scraping-under-50k.csv")

0 commit comments

Comments
 (0)