Skip to content

Commit 0cc1f2b

Browse files
authored
Merge branch 'main' into main
2 parents 6c21107 + 0c719ea commit 0cc1f2b

File tree

23 files changed

+963
-33
lines changed

23 files changed

+963
-33
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ We use github to host code, to track issues and feature requests, as well as acc
1515
## We Use [Github Flow](https://guides.github.com/introduction/flow/index.html), So All Code Changes Happen Through Pull Requests
1616
Pull requests are the best way to propose changes to the codebase (we use [Github Flow](https://guides.github.com/introduction/flow/index.html)). We actively welcome your pull requests:
1717

18-
1. Fork the repo and create your branch from `master`.
18+
1. Fork the repo and create your branch from `main`.
1919
2. If you've added code that should be tested, add tests.
2020
3. If you've changed APIs, update the documentation.
2121
4. Ensure the test suite passes.

Contact-management/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Contact management project
2+
3+
Contact management project is basically a console project developed using python and Sqlite databse,
4+
which can handle CRUD operations easily,following project creates a new db. extension file in your local directory
5+
6+
## Basic feature available :
7+
- User can Add new contact detail
8+
- Can information about current database
9+
- User can delete and manipulate the contacts easily
10+
11+
## About databse management:
12+
I have used "Server-less database" for user to perform CRUD operation locally.
13+
14+
### Libray used in Python:
15+
- Sqlite3 : To handle databse
16+
- Prettytable : To show data in tabular format.
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
from prettytable import PrettyTable
2+
import sqlite3
3+
import os
4+
os.chdir('E:\project')
5+
#--------------------------------------------------
6+
my_database = sqlite3.connect('contact.db')
7+
try:
8+
my_database.execute('select * from contact')
9+
except:
10+
my_database.execute('''CREATE TABLE CONTACT
11+
(NAME char(30) primary key NOT NULL,
12+
Phone_no INT NOT NULL,
13+
ADDRESS CHAR(50),
14+
EMAIL_ID CHAR(50));''')
15+
#--------------------------------------------------------
16+
#print(my_database.execute('select * from contact'))
17+
class contacts:
18+
Name = str()
19+
Mobile_no = str()
20+
Address = str()
21+
Email = str()
22+
def __init__(self):#constructor used for declaring variable
23+
self.Name = ''
24+
self.Mobile_no = ''
25+
self.Address =''
26+
self.Email = ''
27+
def show_table_format(self,contact_detail):
28+
myview = PrettyTable(['Name','Phone no.','Address','Email Id'])
29+
data = []
30+
for i in contact_detail:
31+
data.append(i)
32+
if(not data):
33+
print('oops no data found !!! :(')
34+
return
35+
myview.add_rows(data)
36+
print(myview)
37+
return
38+
39+
def Add_contact(self):
40+
self.Name = input('Enter the name: ')
41+
self.Mobile_no = input('Enter the number: ')
42+
self.Address = input('Enter the address: ')
43+
self.Email = input('Enter the email: ')
44+
45+
my_database.execute('Insert into contact values("{}","{}","{}","{}")'.format(self.Name,self.Mobile_no,self.Address,self.Email))
46+
my_database.commit()
47+
print('Data saved succesfully')
48+
return
49+
50+
def show_contacts(self):
51+
contact_detail = my_database.execute('select * from contact')
52+
self.show_table_format(contact_detail)
53+
54+
def Edit_contacts(self):
55+
self.Delete_contacts()
56+
self.Add_contact()
57+
def Delete_contacts(self):
58+
delete_name = input('Enter the name of contact to edit/delete: ')
59+
60+
my_database.execute('Delete from contact where NAME = "{}" COLLATE NOCASE'.format(delete_name))
61+
my_database.commit()
62+
print('Data deleted succefully')
63+
64+
def search_contacts(self):
65+
search_name = input('Enter the name of contact to search: ')
66+
data = my_database.execute("select * from contact where name = '{}' COLLATE NOCASE".format(search_name))
67+
self.show_table_format(data)
68+
69+
def start_up():
70+
print(' '*15,'1. Press a to add new contact')
71+
print(' '*15,'2. Press s to show contacts')
72+
print(' '*15,'3. Press e to edit contacts')
73+
print(' '*15,'4. Press d to delete contacts')
74+
print(' '*15,'5. Press g to search contacts')
75+
76+
if __name__ == "__main__":
77+
person = contacts()
78+
print('----------------:Welcome to contact list management system:-------------')
79+
80+
answer = 'y'
81+
while answer in ['y','Y']:
82+
start_up()
83+
choice = input('Enter your choice: ')
84+
if choice in ['a','A']:
85+
person.Add_contact()
86+
elif choice in ['s','S']:
87+
person.show_contacts()
88+
elif choice in ['e','E']:
89+
person.Edit_contacts()
90+
elif choice in ['d','D']:
91+
person.Delete_contacts()
92+
elif choice in ['g','G']:
93+
person.search_contacts()
94+
else:
95+
print('oops invalid choice !!! ')
96+
answer = input('Want to perform more operation y/n !!')
97+
print('Programme closed succesfully')
98+
99+
100+
101+
102+

DigitalClock/clock.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1+
# import GUI library - Tkinter
12
from tkinter import *
23
import time
34

45
root = Tk()
6+
7+
# Label the window to "My Clock"
58
root.title('My Clock')
69

10+
#Time calculation
711
def counttime(time1=''):
812
time2 = time.strftime('%H:%M:%S')
913
if time2 != time1:
1014
time1 = time2
1115
clock.config(text=time2)
1216
clock.after(200, counttime)
1317

18+
# Create the clock text
1419
clock = Label(root, font=('Poppins', 50, 'bold'), background='blue', foreground='white')
1520
clock.pack(anchor='center')
1621

22+
# Clock loop
1723
counttime()
1824
mainloop()
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/usr/bin/python3
2+
3+
import argparse
4+
import os
5+
6+
parser = argparse.ArgumentParser(description="Take a directory path or a filename and calculate those sizes in KB")
7+
# Creating an ArgumentParser object
8+
9+
parser.add_argument("-F", help="Choose file prefix for recursive search in directory")
10+
parser.add_argument("path", help="File or directory path for calculating size")
11+
# Adding arguments
12+
13+
group = parser.add_mutually_exclusive_group()
14+
# Creating MutuallyExclusiveGroup object
15+
16+
group.add_argument("-d", action="store_true", help="Directory name for calculate size in KB")
17+
group.add_argument("-f", action="store_true", help="File name for calculate file size in KB")
18+
# Adding mutually exclusive arguments [-d | -f]
19+
20+
args = parser.parse_args()
21+
# Taking arguments from command line
22+
23+
F_argument = args.F
24+
d_argument = args.d
25+
f_argument = args.f
26+
path = args.path
27+
# Unpacking arguments to variables
28+
29+
is_dir = os.path.isdir(path)
30+
# Check if path is a directory not a file
31+
32+
if F_argument and not d_argument and not f_argument:
33+
# If user uses [-F] option lonely
34+
print('[-F] option cannot be used alone')
35+
36+
elif d_argument and is_dir and not f_argument and not F_argument:
37+
# If [-d] used and path is a directory
38+
39+
def get_size(start_path):
40+
total_size = 0
41+
for dirpath, dirnames, filenames in os.walk(start_path):
42+
for f in filenames:
43+
fp = os.path.join(dirpath, f)
44+
# skip if it is symbolic link
45+
if not os.path.islink(fp):
46+
total_size += os.path.getsize(fp) / 1024
47+
# Calculate files sizes and convert to kb
48+
49+
return total_size
50+
51+
52+
print(f"Size of files in directory: {get_size(path):.3f} KB")
53+
54+
elif d_argument and not is_dir and not f_argument and not F_argument:
55+
# If user uses -d option with a file path not a directory
56+
print('Must use a directory path with [ -d ].')
57+
58+
elif f_argument and not is_dir and not d_argument and not F_argument:
59+
# Id [-f] option used and a file name was entered
60+
file_size = os.path.getsize(path) / 1024
61+
# Calculate file size and convert to kb
62+
print(f"Size of file {path} is: {file_size:.3f} KB")
63+
64+
elif f_argument and is_dir and not d_argument and not F_argument:
65+
# If user uses [-f] option with a directory path not a file path
66+
print('Must use [ -f ] with a file name not a directory path')
67+
68+
elif f_argument and F_argument:
69+
# If user uses [-F] option with [-F] option
70+
print('You can not use [-F] option with [-f] option')
71+
72+
elif F_argument and d_argument and is_dir and not f_argument:
73+
# If [-F] for search files with their prefixes in a [-d] directory
74+
def get_size(start_path):
75+
total_size = 0
76+
for dirpath, dirnames, filenames in os.walk(start_path):
77+
for f in filenames:
78+
if f.endswith(F_argument):
79+
fp = os.path.join(dirpath, f)
80+
# skip if it is symbolic link
81+
if not os.path.islink(fp):
82+
total_size += os.path.getsize(fp) / 1024
83+
# Calculate files sizes and convert to kb
84+
85+
return total_size
86+
87+
88+
print(f"Size of {F_argument} files in directory: {get_size(path):.3f} KB")
89+
90+
elif F_argument and d_argument and not is_dir and not f_argument:
91+
# If user uses [-F] option and [-d] option and a file path except directory path
92+
print('Must use [ -d ] option with a directory path')
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# This is a script that getting file and folders sizes
2+
3+
### Its use argparse module to write user-friendly command-line interfaces.
4+
5+
### also use OS module to provides functions for interacting with the operating system.
6+
7+
### How we can use it?
8+
9+
##### python3 GettingSizes.py --help

InstagramBot/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
- firefox browser(for ease of running)
88

99
#### Instructions
10-
Create a folder and name it'nstagram bot', inside the folder create a python file 'instagram.py'
11-
Open the folder in your code editor(VS Code, Pycharm, Sumblime etc.)
10+
Create a folder and name it 'instagram bot', inside the folder create a python file 'instagram.py'
11+
Open the folder in your code editor(VS Code, Pycharm, Sublime etc.)
1212
Open the terminal and cd/foldername and the pip install Instapy
1313

1414
Copy the code and paste in your work file.
@@ -18,5 +18,5 @@ To run the file in the terminal write
1818
python3 'filename'
1919
```
2020

21-
Ant that's it.
22-
Congratulation You have build your First Instagram Bot 👏👏
21+
And that's it.
22+
Congratulations You have built your First Instagram Bot 👏👏

PYDICTIONARY/076 data.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

PYDICTIONARY/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# PYDICTIONARY
2+
3+
## Description
4+
This Python Dictionary works just like a normal dictionary of words and their meanings.
5+
6+
## Steps To Execution
7+
- Fork this repository and navigate to the PYDICTIONARY folder
8+
- Execute the program by running the pydictionary.py file using `$ python pydictionary.py`
9+
- Enter any word of your choice and press enter
10+
- The program will then print out the definition of the word you just entered and thats it!.

PYDICTIONARY/pydictionary.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import json
2+
from difflib import SequenceMatcher
3+
from difflib import get_close_matches
4+
5+
# accessing the data.json file
6+
data = json.load(open("076 data.json"))
7+
8+
# function to check if entered word is present in the 076_data.json file and print neccessary output
9+
def translate(w):
10+
if w in data:
11+
return data[w]
12+
elif w.title() in data:
13+
return data[w.title()]
14+
elif w.upper() in data: #in case user enters words like USA or NATO
15+
return data[w.upper()]
16+
elif len(get_close_matches(w,data.keys())) > 0:
17+
answer = input("Did you mean %s instead? enter Y if yes or N if no:"%get_close_matches(w,data.keys())[0])
18+
answer = answer.lower()
19+
if answer == "y" or answer == "yes":
20+
return data[get_close_matches(w,data.keys())[0]]
21+
elif answer == "n" or answer == "no":
22+
return "TRY ANOTHER WORD:"
23+
else:
24+
return "We didn't Understand what you wanted Type y for yes and n for no: "
25+
else:
26+
print ("THE WORD DOESNT EXIST in the data.json database!!!!! ")
27+
28+
word = input("Enter a word:")
29+
30+
word = word.lower()
31+
32+
print(translate(word))
33+
output = translate(word)
34+
#can comment this below not so neccessary.....
35+
if type(output) == list:
36+
37+
for item in output:
38+
print(item)
39+
else:
40+
print (output)

0 commit comments

Comments
 (0)