├── LICENSE ├── README.md └── Source Code ├── 01_birthday.py ├── 02_stopwatch.py ├── 03_play_youtube_video.py ├── 04_ phonenumber.py ├── 05_screenshot.py ├── 06_audioFromVideo.py ├── 07_textFromPdf.py ├── 08_Write_into_excelsheet.py ├── 09_htmltable_excel.py ├── 10_dictionary.py ├── 11_remove_punc.py ├── 12_shutdown restart Logout ├── LOGOUT.PY ├── Shutdown.py └── restart.py ├── 13_facedetection ├── README.md ├── facedetect.py ├── haarcascade_frontalface_default.xml └── requirement.txt ├── 14_pdftoAudiobook.py ├── 15_textToPdf.py ├── 16_map.py ├── 17_domain_availability.py ├── 18_Clock_turtle.py ├── 19_cleaner.py ├── 20_analog_clock.py ├── 21_alarm.py ├── 22_currency_converter.py ├── 23_zip_extractor.py ├── 24_increase_view_count.py ├── 25_Pikachu.py ├── 26_sound_recorder.py ├── 27_autoFollow.py ├── 28_system_details.py ├── 29_news_notifier.py ├── 30_login_form.py ├── 31_user_authentication_system.py ├── 32_battery_notifier.py ├── 33_internet_speed.py ├── 34_docx_to_pdf.py ├── 35_barcode_generator.py ├── 36_captcha_generator.py ├── 37_cartoonify_image.py ├── 38_sketch_img.py ├── 39_pdf_to_docx.py └── tax ├── MainWindow.py ├── README.md ├── mainwindow.ui └── tax.py /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Insanecodes 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Python 2 | Repository for python Source codes and projects. 3 | -------------------------------------------------------------------------------- /Source Code/01_birthday.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import calendar 3 | 4 | def findDay(date): 5 | born = datetime.datetime.strptime(date,'%d %m %Y') 6 | day = born.weekday() 7 | return (calendar.day_name[day]) 8 | 9 | date = '31 08 2020' 10 | print(findDay(date)) 11 | -------------------------------------------------------------------------------- /Source Code/02_stopwatch.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | print("press Enter to start the stopwatch") 4 | print("and press ctrl + c to stop the the stopwatch") 5 | 6 | while True: 7 | try: 8 | input() 9 | start_time = time.time() 10 | print("stopwatch started") 11 | 12 | except KeyboardInterrupt: 13 | print("stopwatch stopped...") 14 | end_time = time.time() 15 | print("the total time:",round(end_time -start_time,2),"second") 16 | break 17 | -------------------------------------------------------------------------------- /Source Code/03_play_youtube_video.py: -------------------------------------------------------------------------------- 1 | import vlc 2 | import pafy 3 | 4 | url = input("Paste your YouTube URL here:>> ") 5 | 6 | video = pafy.new(url) 7 | best = video.getbest() 8 | 9 | media = vlc.MediaPlayer(best.url) 10 | media.play() 11 | -------------------------------------------------------------------------------- /Source Code/04_ phonenumber.py: -------------------------------------------------------------------------------- 1 | import phonenumbers 2 | from phonenumbers import geocoder 3 | from phonenumbers import carrier 4 | from phonenumbers import timezone 5 | 6 | phone_number = phonenumbers.parse("Enter Number") 7 | # Indian phone number example: 91********** 8 | 9 | print(geocoder.description_for_number(phone_number,'en')) 10 | print(carrier.name_for_number(phone_number,'en')) 11 | print(timezone.time_zones_for_number(phone_number)) 12 | -------------------------------------------------------------------------------- /Source Code/05_screenshot.py: -------------------------------------------------------------------------------- 1 | # Python program to take 2 | # screenshots 3 | 4 | 5 | import numpy as np 6 | import cv2 7 | import pyautogui 8 | 9 | 10 | # take screenshot using pyautogui 11 | image = pyautogui.screenshot() 12 | 13 | # since the pyautogui takes as a 14 | # PIL(pillow) and in RGB we need to 15 | # convert it to numpy array and BGR 16 | # so we can write it to the disk 17 | image = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR) 18 | 19 | # writing it to the disk using opencv 20 | cv2.imwrite("image1.png", image) 21 | -------------------------------------------------------------------------------- /Source Code/06_audioFromVideo.py: -------------------------------------------------------------------------------- 1 | # Python program to extract audio from video 2 | 3 | import moviepy.editor as mp 4 | 5 | # insert Local video File Path 6 | clip = mp.VideoFileClip(r"did.mp4") 7 | 8 | #Insert Local Audio File Path 9 | clip.audio.write_audiofile(r"Audio.mp3") 10 | -------------------------------------------------------------------------------- /Source Code/07_textFromPdf.py: -------------------------------------------------------------------------------- 1 | import PyPDF2 2 | 3 | a = PyPDF2.PdfFileReader('Learning_python.pdf') 4 | 5 | str = "" 6 | 7 | for i in range(0,a.getNumPages()): 8 | str += a.getPage(i).extractText() 9 | 10 | with open('text.txt'."w",encoding='utf-8') as f: 11 | f.write(str) 12 | -------------------------------------------------------------------------------- /Source Code/08_Write_into_excelsheet.py: -------------------------------------------------------------------------------- 1 | import xlwt 2 | from xlwt import Workbook 3 | 4 | wb = Workbook() 5 | sheet1 = wb.add_sheet('sheet 1') 6 | 7 | sheet1.write(1,0,'Rohan') 8 | sheet1.write(2,0,'Rahul') 9 | sheet1.write(3,0,'Subh') 10 | sheet1.write(4,0,'Rajan') 11 | sheet1.write(0,1,'Rohan') 12 | sheet1.write(0,2,'Rahul') 13 | sheet1.write(0,3,'subh') 14 | sheet1.write(0,4,'Rajan') 15 | 16 | wb.save('example.xls') 17 | -------------------------------------------------------------------------------- /Source Code/09_htmltable_excel.py: -------------------------------------------------------------------------------- 1 | #python program to write HTML table into Excel Sheet 2 | 3 | # import pandas 4 | import pandas as pd 5 | 6 | 7 | # the webpage URL whose table you want to extract 8 | url = "Enter url here" 9 | 10 | # assign the table data to a Pandasa dataframe 11 | table = pd.read_html(url)[3] 12 | 13 | #store the dataframe in excel file 14 | table.to_excel("data.xlsx") 15 | -------------------------------------------------------------------------------- /Source Code/10_dictionary.py: -------------------------------------------------------------------------------- 1 | from PyDictionary import PyDictionary 2 | 3 | dict = PyDictionary() 4 | 5 | query = input("Entyer your query: ") 6 | 7 | meaning = dict.meaning(query) 8 | 9 | print(meaning) 10 | -------------------------------------------------------------------------------- /Source Code/11_remove_punc.py: -------------------------------------------------------------------------------- 1 | #python program to remove punctuations 2 | 3 | String = input("Enter String: ") 4 | 5 | Punctuations = '''!()-[]}{;:'"\,<>./?@#$%^&*_~`''' 6 | 7 | Remove_punc = "" 8 | 9 | for char in String: 10 | if char not in Punctuations: 11 | Remove_punc = Remove_punc + char 12 | 13 | print(Remove_punc) -------------------------------------------------------------------------------- /Source Code/12_shutdown restart Logout/LOGOUT.PY: -------------------------------------------------------------------------------- 1 | import os 2 | logout = input("Do you wish to shutdown your computer? (yes/no): ") 3 | 4 | # if shutdown == 'no': 5 | # exit() 6 | # else: 7 | # os.system("shutdown /s /t 1") 8 | if logout == "yes": 9 | os.system("shutdown -l") 10 | else: 11 | exit() -------------------------------------------------------------------------------- /Source Code/12_shutdown restart Logout/Shutdown.py: -------------------------------------------------------------------------------- 1 | import os 2 | shutdown = input("Do you wish to shutdown your computer? (yes/no): ") 3 | 4 | if shutdown == "yes": 5 | os.system("shutdown /s /t 1") 6 | else: 7 | exit() -------------------------------------------------------------------------------- /Source Code/12_shutdown restart Logout/restart.py: -------------------------------------------------------------------------------- 1 | import os 2 | restart = input("Do you wish to shutdown your computer? (yes/no): ") 3 | 4 | # if shutdown == 'no': 5 | # exit() 6 | # else: 7 | # os.system("shutdown /s /t 1") 8 | if restart == "yes": 9 | os.system("shutdown /r /t 1") 10 | else: 11 | exit() -------------------------------------------------------------------------------- /Source Code/13_facedetection/README.md: -------------------------------------------------------------------------------- 1 | Face Detection using OpenCV 2 | -------------------------------------------------------------------------------- /Source Code/13_facedetection/facedetect.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | # Load the cascade 4 | face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml') 5 | 6 | # To capture video from webcam. 7 | cap = cv2.VideoCapture(0) 8 | # To use a video file as input 9 | # cap = cv2.VideoCapture('filename.mp4') 10 | 11 | while True: 12 | # Read the frame 13 | _, img = cap.read() 14 | 15 | # Convert to grayscale 16 | gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 17 | 18 | # Detect the faces 19 | faces = face_cascade.detectMultiScale(gray, 1.1, 4) 20 | 21 | # Draw the rectangle around each face 22 | for (x, y, w, h) in faces: 23 | cv2.rectangle(img, (x, y), (x+w, y+h), (255, 0, 0), 2) 24 | 25 | # Display 26 | cv2.imshow('img', img) 27 | 28 | # Stop if escape key is pressed 29 | k = cv2.waitKey(30) & 0xff 30 | if k==27: 31 | break 32 | 33 | # Release the VideoCapture object 34 | cap.release() -------------------------------------------------------------------------------- /Source Code/13_facedetection/requirement.txt: -------------------------------------------------------------------------------- 1 | OpenCv 2 | Numpy 3 | -------------------------------------------------------------------------------- /Source Code/14_pdftoAudiobook.py: -------------------------------------------------------------------------------- 1 | #A python program to convert PDF into Audiobook 2 | 3 | import PyPDF2 4 | import pyttsx3 5 | from tkinter.filedialog import * 6 | 7 | 8 | root = Tk() 9 | root.title("Pdf to Audiobook") 10 | # Open Dialogbox that requests selection of an existing file 11 | book = askopenfilename() 12 | 13 | #reading the pdf file and storing in str 14 | a = PyPDF2.PdfFileReader(book) 15 | str = "" 16 | for i in range(0,a.getNumPages()): 17 | str += a.getPage(i).extractText() 18 | 19 | # init function to get an engine instance for the speech synthesis 20 | engine = pyttsx3.init() 21 | engine.say(str) 22 | engine.runAndWait() 23 | -------------------------------------------------------------------------------- /Source Code/15_textToPdf.py: -------------------------------------------------------------------------------- 1 | #Python program to convert a text file into pdf 2 | 3 | from fpdf import FPDF 4 | 5 | # save FPDF() class into a variable pdf 6 | pdf = FPDF() 7 | 8 | # Add a page 9 | pdf.add_page() 10 | 11 | # set style and size of font 12 | # that you want in the pdf 13 | pdf.set_font("Arial", size = 15) 14 | 15 | # open the text file in read mode 16 | f = open("myfile.txt", "r") 17 | 18 | # insert the texts in pdf 19 | for x in f: 20 | pdf.cell(200, 10, txt = x, ln = 1, align = 'C') 21 | 22 | # save the pdf with name .pdf 23 | pdf.output("insane.pdf") 24 | -------------------------------------------------------------------------------- /Source Code/16_map.py: -------------------------------------------------------------------------------- 1 | # Python program to open map in web browser 2 | import folium 3 | import webbrowser 4 | import os 5 | 6 | 7 | # Map method of folium return Map object 8 | # Here we pass coordinates 9 | geo= folium.Map(location=[28.457523,77.026344]) 10 | 11 | 12 | # save method of Map object will create a map 13 | geo.save('index.html') 14 | 15 | 16 | #Open html file in web browser 17 | webbrowser.open('file://' + os.path.realpath('index.html')) -------------------------------------------------------------------------------- /Source Code/17_domain_availability.py: -------------------------------------------------------------------------------- 1 | # Python program to check domain avaliability 2 | import whois 3 | import socket 4 | 5 | # function to test internet connection 6 | def test_connection(): 7 | try: 8 | socket.create_connection(('Google.com', 80)) 9 | return True 10 | except OSError: 11 | return 12 | 13 | # driver code 14 | if __name__ == "__main__": 15 | test = test_connection() 16 | if test == True: 17 | check = input("Enter the domain name to check: ") 18 | domain = whois.whois(check) 19 | if domain.domain_name == None: 20 | print("this domain is available") 21 | else: 22 | print("Sorry! This domain already purchased") 23 | else: 24 | print("You are not connected to internet") 25 | -------------------------------------------------------------------------------- /Source Code/18_Clock_turtle.py: -------------------------------------------------------------------------------- 1 | # Python program to Create digital clock using Python-Turtle 2 | import time 3 | import datetime as dt 4 | import turtle 5 | 6 | 7 | # create a turtle to distplay time 8 | t = turtle.Turtle() 9 | 10 | # create a turtle to create rectangle box 11 | t1 = turtle.Turtle() 12 | 13 | # create screen 14 | s = turtle.Screen() 15 | 16 | # set background color of the screen 17 | s.bgcolor("white") 18 | 19 | # obtain current hour, minute and second 20 | # from the system 21 | sec = dt.datetime.now().second 22 | min = dt.datetime.now().minute 23 | hr = dt.datetime.now().hour 24 | t1.pensize(3) 25 | t1.color('black') 26 | t1.penup() 27 | 28 | # set the position of turtle 29 | t1.goto(-20, 0) 30 | t1.pendown() 31 | 32 | # create rectangular box 33 | for i in range(2): 34 | t1.forward(200) 35 | t1.left(90) 36 | t1.forward(55) 37 | t1.left(90) 38 | 39 | # hide the turtle 40 | t1.hideturtle() 41 | 42 | while True: 43 | t.hideturtle() 44 | t.clear() 45 | # display the time 46 | t.write(str(hr).zfill(2) 47 | +":"+str(min).zfill(2)+":" 48 | +str(sec).zfill(2), 49 | font =("Arial Narrow", 35, "bold")) 50 | time.sleep(1) 51 | sec+= 1 52 | 53 | if sec == 60: 54 | sec = 0 55 | min+= 1 56 | 57 | if min == 60: 58 | min = 0 59 | hr+= 1 60 | 61 | if hr == 13: 62 | hr = 1 -------------------------------------------------------------------------------- /Source Code/19_cleaner.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | def createIfNotExist(folder): 4 | '''Create folder if not exist''' 5 | if not os.path.exists(folder): 6 | os.makedirs(folder) 7 | 8 | def move(files,foldername): 9 | '''Move files to their respective folders ''' 10 | for file in files: 11 | os.replace(file,f"{foldername}/{file}") 12 | 13 | 14 | if __name__ == "__main__": 15 | # return list containing the names of the entries in the directory given by path. 16 | files = os.listdir() 17 | files.remove("cleaner.py") #remove source file from the list 18 | 19 | # function call createIfNotExist 20 | createIfNotExist('Images') 21 | createIfNotExist('Docs') 22 | createIfNotExist('Media') 23 | createIfNotExist('Others') 24 | 25 | 26 | imgExts = [".png",".jpg",".jpeg"] 27 | # return list containing the file name having extension defined in imgExts and stored in images 28 | images = [file for file in files if os.path.splitext(file)[1].lower() in imgExts] 29 | 30 | 31 | docExts = [".txt", ".docx",".doc",".pdf"] 32 | # return list containing the file name having extension defined in docExts and stored in docs 33 | docs = [file for file in files if os.path.splitext(file)[1].lower() in docExts] 34 | 35 | mediaExts = [".mp3", ".mp4",".flv"] 36 | # return list containing the file name having extension defined in mediaExts and stored in medias 37 | medias = [file for file in files if os.path.splitext(file)[1].lower() in mediaExts] 38 | 39 | others = [] 40 | for file in files: 41 | ext = os.path.splitext(file)[1].lower() 42 | if (ext not in imgExts) and (ext not in docExts) and (ext not in mediaExts) and os.path.isfile(file): 43 | others.append(file) 44 | 45 | # function call move 46 | move(images,"Images") 47 | move(docs,"Docs") 48 | move(medias,"Media") 49 | move(others,"Others") 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /Source Code/20_analog_clock.py: -------------------------------------------------------------------------------- 1 | # Create Analog Clock Using Python 2 | import turtle 3 | import time 4 | 5 | window = turtle.Screen() 6 | window.bgcolor("black") 7 | window.setup(width=600, height=600) 8 | window.title("Analog Clock") 9 | window.tracer(0) 10 | 11 | # Create the drawing pen 12 | pen = turtle.Turtle() 13 | pen.hideturtle() 14 | pen.speed(0) 15 | pen.pensize(3) 16 | 17 | 18 | def draw_clock(hr, mn, sec, pen): 19 | 20 | # Draw clock face 21 | pen.up() 22 | pen.goto(0, 210) 23 | pen.setheading(180) 24 | pen.color("purple") 25 | pen.pendown() 26 | pen.circle(210) 27 | 28 | # Draw hour hashes 29 | pen.up() 30 | pen.goto(0, 0) 31 | pen.setheading(90) 32 | 33 | for _ in range(12): 34 | pen.fd(190) 35 | pen.pendown() 36 | pen.fd(20) 37 | pen.penup() 38 | pen.goto(0, 0) 39 | pen.rt(30) 40 | 41 | # Draw the hands 42 | # Each tuple in list hands describes the color, the length 43 | # and the divisor for the angle 44 | hands = [("white", 80, 12), ("blue", 150, 60), ("red", 110, 60)] 45 | time_set = (hr, mn, sec) 46 | 47 | for hand in hands: 48 | time_part = time_set[hands.index(hand)] 49 | angle = (time_part/hand[2])*360 50 | pen.penup() 51 | pen.goto(0, 0) 52 | pen.color(hand[0]) 53 | pen.setheading(90) 54 | pen.rt(angle) 55 | pen.pendown() 56 | pen.fd(hand[1]) 57 | 58 | 59 | while True: 60 | hr = int(time.strftime("%I")) 61 | mn = int(time.strftime("%M")) 62 | sec = int(time.strftime("%S")) 63 | 64 | draw_clock(hr, mn, sec, pen) 65 | window.update() 66 | time.sleep(1) 67 | pen.clear() 68 | 69 | window.mainloop() -------------------------------------------------------------------------------- /Source Code/21_alarm.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | import datetime 3 | import time 4 | import pygame 5 | 6 | 7 | def alarm(set_alarm_timer): 8 | while True: 9 | time.sleep(1) 10 | current_time = datetime.datetime.now() 11 | now = current_time.strftime("%H:%M:%S") 12 | date = current_time.strftime("%d/%m/%Y") 13 | print(now) 14 | if now == set_alarm_timer: 15 | print("Time to Wake up") 16 | pygame.mixer.init() 17 | pygame.mixer.music.load("music.mp3") 18 | pygame.mixer.music.play() 19 | break 20 | 21 | 22 | def actual_time(): 23 | set_alarm_timer = f"{hour.get()}:{min.get()}:{sec.get()}" 24 | alarm(set_alarm_timer) 25 | 26 | 27 | clock = Tk() 28 | clock.title("Alarm Clock") 29 | clock.geometry("350x250") 30 | time_format = Label(clock, text="Enter time in 24 hour format!", 31 | fg="red", bg="blue", font="Arial").place(x=50, y=140) 32 | addTime = Label(clock, text="Hour Min Sec", font=60).place(x=150, y=20) 33 | setYourAlarm = Label(clock, text="When to wake you up", fg="blue", 34 | relief="solid", font=("Arial", 8, "bold")).place(x=10, y=50) 35 | 36 | 37 | # The Variables we require to set the alarm(initialization): 38 | hour = StringVar() 39 | min = StringVar() 40 | sec = StringVar() 41 | 42 | # Time required to set the alarm clock: 43 | hourTime = Entry(clock, textvariable=hour, bg="pink", 44 | width=5).place(x=150, y=50) 45 | minTime = Entry(clock, textvariable=min, bg="pink", 46 | width=5).place(x=190, y=50) 47 | secTime = Entry(clock, textvariable=sec, bg="pink", 48 | width=5).place(x=230, y=50) 49 | 50 | # To take the time input by user: 51 | submit = Button(clock, text="Set Alarm", fg="red", width=10, 52 | command=actual_time).place(x=110, y=90) 53 | 54 | 55 | # Execution of the window. 56 | clock.mainloop() 57 | -------------------------------------------------------------------------------- /Source Code/22_currency_converter.py: -------------------------------------------------------------------------------- 1 | # Currency Converter using python tkinter 2 | 3 | # import all functions from the tkinter 4 | from tkinter import * 5 | 6 | # Create a GUI window 7 | root = Tk() 8 | 9 | 10 | # create a global variables 11 | variable1 = StringVar(root) 12 | variable2 = StringVar(root) 13 | 14 | # initialise the variables 15 | variable1.set("currency") 16 | variable2.set("currency") 17 | 18 | 19 | # Function to perform real time conversion 20 | # from one currency to another currency 21 | def RealTimeCurrencyConversion(): 22 | # importing required libraries 23 | import requests 24 | import json 25 | 26 | # currency code 27 | from_currency = variable1.get() 28 | to_currency = variable2.get() 29 | 30 | # enter your api key here 31 | api_key = "USWFI32A8H33EE48" 32 | 33 | # base_url variable store base url 34 | base_url = r"https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE" 35 | 36 | # main_url variable store complete url 37 | main_url = base_url + "&from_currency=" + from_currency + \ 38 | "&to_currency=" + to_currency + "&apikey=" + api_key 39 | # get method of requests module 40 | # return response object 41 | req_ob = requests.get(main_url) 42 | 43 | # json method return json format 44 | # data into python dictionary data type. 45 | 46 | # result contains list of nested dictionaries 47 | result = req_ob.json() 48 | 49 | # parsing the required information 50 | Exchange_Rate = float( 51 | result["Realtime Currency Exchange Rate"]["5. Exchange Rate"]) 52 | 53 | # get method of Entry widget 54 | # returns current text as a 55 | # string from text entry box. 56 | amount = float(Amount1_field.get()) 57 | 58 | # calculation for the conversion 59 | new_amount = round(amount * Exchange_Rate, 3) 60 | 61 | # insert method inserting the 62 | # value in the text entry box. 63 | Amount2_field.insert(0, str(new_amount)) 64 | 65 | 66 | # Function for clearing the Entry field 67 | def clear_all(): 68 | Amount1_field.delete(0, END) 69 | Amount2_field.delete(0, END) 70 | 71 | 72 | # Driver code 73 | if __name__ == "__main__": 74 | 75 | # Set the background colour of GUI window 76 | root.configure(background='light green') 77 | 78 | # Set the title of GUI window 79 | root.title("Currency Converter") 80 | 81 | # Set the configuration of GUI window (WidthxHeight) 82 | root.geometry("450x250") 83 | 84 | # Create welcome to Real Time Currency Convertor label 85 | headlabel = Label(root, text='welcome to Real Time Currency Convertor', 86 | fg='white', bg="red", font="bold") 87 | 88 | # Create a "Amount :" label 89 | label1 = Label(root, text="Amount :", fg='white', bg='dark green') 90 | 91 | # Create a "From Currency :" label 92 | label2 = Label(root, text="From Currency", fg='white', bg='dark green') 93 | 94 | # Create a "To Currency: " label 95 | label3 = Label(root, text="To Currency :", fg='white', bg='dark green') 96 | 97 | # Create a "Converted Amount :" label 98 | label4 = Label(root, text="Converted Amount :", 99 | fg='white', bg='dark green') 100 | 101 | # grid method is used for placing 102 | # the widgets at respective positions 103 | # in table like structure . 104 | headlabel.grid(row=0, column=1) 105 | label1.grid(row=1, column=0) 106 | label2.grid(row=2, column=0) 107 | label3.grid(row=3, column=0) 108 | label4.grid(row=5, column=0) 109 | 110 | # Create a text entry box 111 | # for filling or typing the information. 112 | Amount1_field = Entry(root) 113 | Amount2_field = Entry(root) 114 | 115 | # ipadx keyword argument set width of entry space. 116 | Amount1_field.grid(row=1, column=1, ipadx="25") 117 | Amount2_field.grid(row=5, column=1, ipadx="25") 118 | 119 | # list of currency codes 120 | CurrenyCode_list = ["INR", "USD", "CAD", "CNY", "DKK", "EUR"] 121 | 122 | # create a drop down menu using OptionMenu function 123 | # which takes window name, variable and choices as 124 | # an argument. use * befor the name of the list, 125 | # to unpack the values 126 | FromCurrency_option = OptionMenu(root, variable1, *CurrenyCode_list) 127 | ToCurrency_option = OptionMenu(root, variable2, *CurrenyCode_list) 128 | 129 | FromCurrency_option.grid(row=2, column=1, ipadx=10) 130 | ToCurrency_option.grid(row=3, column=1, ipadx=10) 131 | 132 | # Create a Convert Button and attached 133 | # with RealTimeCurrencyExchangeRate function 134 | button1 = Button(root, text="Convert", bg="red", 135 | fg="black", command=RealTimeCurrencyConversion) 136 | 137 | button1.grid(row=4, column=1) 138 | 139 | # Create a Clear Button and attached 140 | # with delete function 141 | button2 = Button(root, text="Clear", bg="red", 142 | fg="black", command=clear_all) 143 | button2.grid(row=6, column=1) 144 | 145 | # Start the GUI 146 | root.mainloop() 147 | -------------------------------------------------------------------------------- /Source Code/23_zip_extractor.py: -------------------------------------------------------------------------------- 1 | # importing required modules 2 | from zipfile import ZipFile 3 | 4 | # specifying the zip file name 5 | file_name = "assignment.zip" 6 | 7 | # opening the zip file in READ mode 8 | with ZipFile(file_name, 'r') as zip: 9 | # printing all the contents of the zip file 10 | zip.printdir() 11 | 12 | # extracting all the files 13 | print('Extracting all the files now...') 14 | zip.extractall() 15 | print('Done!') 16 | -------------------------------------------------------------------------------- /Source Code/24_increase_view_count.py: -------------------------------------------------------------------------------- 1 | from selenium import webdriver 2 | from selenium.webdriver.common.keys import Keys 3 | import time 4 | 5 | # set webdriver path here it may vary 6 | driver = webdriver.Chrome(executable_path="C:\Drivers\chromedriver.exe") 7 | 8 | website_URL = "https://www.python.org/" 9 | driver.get(website_URL) 10 | 11 | # After how many seconds you want to refresh the webpage 12 | # Few website count view if you stay there 13 | # for a particular time 14 | # you have to figure that out 15 | refreshrate = int(5) 16 | 17 | # This would keep running until you stop the compiler. 18 | while True: 19 | time.sleep(refreshrate) 20 | driver.refresh() 21 | -------------------------------------------------------------------------------- /Source Code/25_Pikachu.py: -------------------------------------------------------------------------------- 1 | #pikachu animation using python-turtle 2 | import turtle 3 | def getPosition(x, y): 4 | turtle.setx(x) 5 | turtle.sety(y) 6 | print(x, y) 7 | 8 | 9 | class Pikachu: 10 | def __init__(self): 11 | self.t = turtle.Turtle() 12 | t = self.t 13 | t.pensize(3) 14 | t.speed(9) 15 | t.ondrag(getPosition) 16 | 17 | def noTrace_goto(self, x, y): 18 | self.t.penup() 19 | self.t.goto(x, y) 20 | self.t.pendown() 21 | 22 | def leftEye(self, x, y): 23 | self.noTrace_goto(x, y) 24 | t = self.t 25 | t.seth(0) 26 | t.fillcolor('#333333') 27 | t.begin_fill() 28 | t.circle(22) 29 | t.end_fill() 30 | 31 | self.noTrace_goto(x, y+10) 32 | t.fillcolor('#000000') 33 | t.begin_fill() 34 | t.circle(10) 35 | t.end_fill() 36 | 37 | self.noTrace_goto(x+6, y + 22) 38 | t.fillcolor('#ffffff') 39 | t.begin_fill() 40 | t.circle(10) 41 | t.end_fill() 42 | 43 | def rightEye(self, x, y): 44 | self.noTrace_goto(x, y) 45 | t = self.t 46 | t.seth(0) 47 | t.fillcolor('#333333') 48 | t.begin_fill() 49 | t.circle(22) 50 | t.end_fill() 51 | 52 | self.noTrace_goto(x, y+10) 53 | t.fillcolor('#000000') 54 | t.begin_fill() 55 | t.circle(10) 56 | t.end_fill() 57 | 58 | self.noTrace_goto(x-6, y + 22) 59 | t.fillcolor('#ffffff') 60 | t.begin_fill() 61 | t.circle(10) 62 | t.end_fill() 63 | 64 | def mouth(self, x, y): 65 | self.noTrace_goto(x, y) 66 | t = self.t 67 | 68 | t.fillcolor('#88141D') 69 | t.begin_fill() 70 | # lower lip 71 | l1 = [] 72 | l2 = [] 73 | t.seth(190) 74 | a = 0.7 75 | for i in range(28): 76 | a += 0.1 77 | t.right(3) 78 | t.fd(a) 79 | l1.append(t.position()) 80 | 81 | self.noTrace_goto(x, y) 82 | 83 | t.seth(10) 84 | a = 0.7 85 | for i in range(28): 86 | a += 0.1 87 | t.left(3) 88 | t.fd(a) 89 | l2.append(t.position()) 90 | 91 | # Upper lip 92 | t.seth(10) 93 | t.circle(50, 15) 94 | t.left(180) 95 | t.circle(-50, 15) 96 | 97 | t.circle(-50, 40) 98 | t.seth(233) 99 | t.circle(-50, 55) 100 | t.left(180) 101 | t.circle(50, 12.1) 102 | t.end_fill() 103 | 104 | # tongue 105 | self.noTrace_goto(17, 54) 106 | t.fillcolor('#DD716F') 107 | t.begin_fill() 108 | t.seth(145) 109 | t.circle(40, 86) 110 | t.penup() 111 | for pos in reversed(l1[:20]): 112 | t.goto(pos[0], pos[1]+1.5) 113 | for pos in l2[:20]: 114 | t.goto(pos[0], pos[1]+1.5) 115 | t.pendown() 116 | t.end_fill() 117 | 118 | # nose 119 | self.noTrace_goto(-17, 94) 120 | t.seth(8) 121 | t.fd(4) 122 | t.back(8) 123 | 124 | # Red cheeks 125 | def leftCheek(self, x, y): 126 | turtle.tracer(False) 127 | t = self.t 128 | self.noTrace_goto(x, y) 129 | t.seth(300) 130 | t.fillcolor('#DD4D28') 131 | t.begin_fill() 132 | a = 2.3 133 | for i in range(120): 134 | if 0 <= i < 30 or 60 <= i < 90: 135 | a -= 0.05 136 | t.lt(3) 137 | t.fd(a) 138 | else: 139 | a += 0.05 140 | t.lt(3) 141 | t.fd(a) 142 | t.end_fill() 143 | turtle.tracer(True) 144 | 145 | def rightCheek(self, x, y): 146 | t = self.t 147 | turtle.tracer(False) 148 | self.noTrace_goto(x, y) 149 | t.seth(60) 150 | t.fillcolor('#DD4D28') 151 | t.begin_fill() 152 | a = 2.3 153 | for i in range(120): 154 | if 0 <= i < 30 or 60 <= i < 90: 155 | a -= 0.05 156 | t.lt(3) 157 | t.fd(a) 158 | else: 159 | a += 0.05 160 | t.lt(3) 161 | t.fd(a) 162 | t.end_fill() 163 | turtle.tracer(True) 164 | 165 | def colorLeftEar(self, x, y): 166 | t = self.t 167 | self.noTrace_goto(x, y) 168 | t.fillcolor('#000000') 169 | t.begin_fill() 170 | t.seth(330) 171 | t.circle(100, 35) 172 | t.seth(219) 173 | t.circle(-300, 19) 174 | t.seth(110) 175 | t.circle(-30, 50) 176 | t.circle(-300, 10) 177 | t.end_fill() 178 | 179 | def colorRightEar(self, x, y): 180 | t = self.t 181 | self.noTrace_goto(x, y) 182 | t.fillcolor('#000000') 183 | t.begin_fill() 184 | t.seth(300) 185 | t.circle(-100, 30) 186 | t.seth(35) 187 | t.circle(300, 15) 188 | t.circle(30, 50) 189 | t.seth(190) 190 | t.circle(300, 17) 191 | t.end_fill() 192 | 193 | def body(self): 194 | t = self.t 195 | 196 | t.fillcolor('#F6D02F') 197 | t.begin_fill() 198 | # Right face Contour 199 | t.penup() 200 | t.circle(130, 40) 201 | t.pendown() 202 | t.circle(100, 105) 203 | t.left(180) 204 | t.circle(-100, 5) 205 | 206 | # Right ear 207 | t.seth(20) 208 | t.circle(300, 30) 209 | t.circle(30, 50) 210 | t.seth(190) 211 | t.circle(300, 36) 212 | 213 | # upper profile 214 | t.seth(150) 215 | t.circle(150, 70) 216 | 217 | # left ear 218 | t.seth(200) 219 | t.circle(300, 40) 220 | t.circle(30, 50) 221 | t.seth(20) 222 | t.circle(300, 35) 223 | # print(t.pos()) 224 | 225 | # Left face contour 226 | t.seth(240) 227 | t.circle(105, 95) 228 | t.left(180) 229 | t.circle(-105, 5) 230 | 231 | # left hand 232 | t.seth(210) 233 | t.circle(500, 18) 234 | t.seth(200) 235 | t.fd(10) 236 | t.seth(280) 237 | t.fd(7) 238 | t.seth(210) 239 | t.fd(10) 240 | t.seth(300) 241 | t.circle(10, 80) 242 | t.seth(220) 243 | t.fd(10) 244 | t.seth(300) 245 | t.circle(10, 80) 246 | t.seth(240) 247 | t.fd(12) 248 | t.seth(0) 249 | t.fd(13) 250 | t.seth(240) 251 | t.circle(10, 70) 252 | t.seth(10) 253 | t.circle(10, 70) 254 | t.seth(10) 255 | t.circle(300, 18) 256 | 257 | t.seth(75) 258 | t.circle(500, 8) 259 | t.left(180) 260 | t.circle(-500, 15) 261 | t.seth(250) 262 | t.circle(100, 65) 263 | 264 | # left foot 265 | t.seth(320) 266 | t.circle(100, 5) 267 | t.left(180) 268 | t.circle(-100, 5) 269 | t.seth(220) 270 | t.circle(200, 20) 271 | t.circle(20, 70) 272 | 273 | t.seth(60) 274 | t.circle(-100, 20) 275 | t.left(180) 276 | t.circle(100, 20) 277 | t.seth(300) 278 | t.circle(10, 70) 279 | 280 | t.seth(60) 281 | t.circle(-100, 20) 282 | t.left(180) 283 | t.circle(100, 20) 284 | t.seth(10) 285 | t.circle(100, 60) 286 | 287 | 288 | t.seth(180) 289 | t.circle(-100, 10) 290 | t.left(180) 291 | t.circle(100, 10) 292 | t.seth(5) 293 | t.circle(100, 10) 294 | t.circle(-100, 40) 295 | t.circle(100, 35) 296 | t.left(180) 297 | t.circle(-100, 10) 298 | 299 | # Right foot 300 | t.seth(290) 301 | t.circle(100, 55) 302 | t.circle(10, 50) 303 | 304 | t.seth(120) 305 | t.circle(100, 20) 306 | t.left(180) 307 | t.circle(-100, 20) 308 | 309 | t.seth(0) 310 | t.circle(10, 50) 311 | 312 | t.seth(110) 313 | t.circle(100, 20) 314 | t.left(180) 315 | t.circle(-100, 20) 316 | 317 | t.seth(30) 318 | t.circle(20, 50) 319 | 320 | t.seth(100) 321 | t.circle(100, 40) 322 | 323 | # Right body contour 324 | t.seth(200) 325 | t.circle(-100, 5) 326 | t.left(180) 327 | t.circle(100, 5) 328 | t.left(30) 329 | t.circle(100, 75) 330 | t.right(15) 331 | t.circle(-300, 21) 332 | t.left(180) 333 | t.circle(300, 3) 334 | 335 | # Right hand 336 | t.seth(43) 337 | t.circle(200, 60) 338 | 339 | t.right(10) 340 | t.fd(10) 341 | 342 | t.circle(5, 160) 343 | t.seth(90) 344 | t.circle(5, 160) 345 | t.seth(90) 346 | 347 | t.fd(10) 348 | t.seth(90) 349 | t.circle(5, 180) 350 | t.fd(10) 351 | 352 | t.left(180) 353 | t.left(20) 354 | t.fd(10) 355 | t.circle(5, 170) 356 | t.fd(10) 357 | t.seth(240) 358 | t.circle(50, 30) 359 | 360 | t.end_fill() 361 | self.noTrace_goto(130, 125) 362 | t.seth(-20) 363 | t.fd(5) 364 | t.circle(-5, 160) 365 | t.fd(5) 366 | 367 | # Fingerprint 368 | self.noTrace_goto(166, 130) 369 | t.seth(-90) 370 | t.fd(3) 371 | t.circle(-4, 180) 372 | t.fd(3) 373 | t.seth(-90) 374 | t.fd(3) 375 | t.circle(-4, 180) 376 | t.fd(3) 377 | 378 | # tail 379 | self.noTrace_goto(168, 134) 380 | t.fillcolor('#F6D02F') 381 | t.begin_fill() 382 | t.seth(40) 383 | t.fd(200) 384 | t.seth(-80) 385 | t.fd(150) 386 | t.seth(210) 387 | t.fd(150) 388 | t.left(90) 389 | t.fd(100) 390 | t.right(95) 391 | t.fd(100) 392 | t.left(110) 393 | t.fd(70) 394 | t.right(110) 395 | t.fd(80) 396 | t.left(110) 397 | t.fd(30) 398 | t.right(110) 399 | t.fd(32) 400 | 401 | t.right(106) 402 | t.circle(100, 25) 403 | t.right(15) 404 | t.circle(-300, 2) 405 | t.seth(30) 406 | t.fd(40) 407 | t.left(100) 408 | t.fd(70) 409 | t.right(100) 410 | t.fd(80) 411 | t.left(100) 412 | t.fd(46) 413 | t.seth(66) 414 | t.circle(200, 38) 415 | t.right(10) 416 | t.fd(10) 417 | t.end_fill() 418 | 419 | # Tail pattern 420 | t.fillcolor('#923E24') 421 | self.noTrace_goto(126.82, -156.84) 422 | t.begin_fill() 423 | 424 | t.seth(30) 425 | t.fd(40) 426 | t.left(100) 427 | t.fd(40) 428 | t.pencolor('#923e24') 429 | t.seth(-30) 430 | t.fd(30) 431 | t.left(140) 432 | t.fd(20) 433 | t.right(150) 434 | t.fd(20) 435 | t.left(150) 436 | t.fd(20) 437 | t.right(150) 438 | t.fd(20) 439 | t.left(130) 440 | t.fd(18) 441 | t.pencolor('#000000') 442 | t.seth(-45) 443 | t.fd(67) 444 | t.right(110) 445 | t.fd(80) 446 | t.left(110) 447 | t.fd(30) 448 | t.right(110) 449 | t.fd(32) 450 | t.right(106) 451 | t.circle(100, 25) 452 | t.right(15) 453 | t.circle(-300, 2) 454 | t.end_fill() 455 | 456 | # Hat, eyes, mouth, cheeks 457 | self.cap(-134.07, 147.81) 458 | self.mouth(-5, 25) 459 | self.leftCheek(-126, 32) 460 | self.rightCheek(107, 63) 461 | self.colorLeftEar(-250, 100) 462 | self.colorRightEar(140, 270) 463 | self.leftEye(-85, 90) 464 | self.rightEye(50, 110) 465 | t.hideturtle() 466 | 467 | def cap(self, x, y): 468 | self.noTrace_goto(x, y) 469 | t = self.t 470 | t.fillcolor('#CD0000') 471 | t.begin_fill() 472 | t.seth(200) 473 | t.circle(400, 7) 474 | t.left(180) 475 | t.circle(-400, 30) 476 | t.circle(30, 60) 477 | t.fd(50) 478 | t.circle(30, 45) 479 | t.fd(60) 480 | t.left(5) 481 | t.circle(30, 70) 482 | t.right(20) 483 | t.circle(200, 70) 484 | t.circle(30, 60) 485 | t.fd(70) 486 | t.right(35) 487 | t.fd(50) 488 | t.circle(8, 100) 489 | t.end_fill() 490 | self.noTrace_goto(-168.47, 185.52) 491 | t.seth(36) 492 | t.circle(-270, 54) 493 | t.left(180) 494 | t.circle(270, 27) 495 | t.circle(-80, 98) 496 | 497 | t.fillcolor('#444444') 498 | t.begin_fill() 499 | t.left(180) 500 | t.circle(80, 197) 501 | t.left(58) 502 | t.circle(200, 45) 503 | t.end_fill() 504 | 505 | self.noTrace_goto(-58, 270) 506 | t.pencolor('#228B22') 507 | t.dot(35) 508 | 509 | self.noTrace_goto(-30, 280) 510 | t.fillcolor('#228B22') 511 | t.begin_fill() 512 | t.seth(100) 513 | t.circle(30, 180) 514 | t.seth(190) 515 | t.fd(15) 516 | t.seth(100) 517 | t.circle(-45, 180) 518 | t.right(90) 519 | t.fd(15) 520 | t.end_fill() 521 | t.pencolor('#000000') 522 | 523 | def start(self): 524 | self.body() 525 | 526 | 527 | def main(): 528 | print('Started Painting the Pikachu... ') 529 | turtle.screensize(800, 600) 530 | turtle.title('Pikachu') 531 | pikachu = Pikachu() 532 | pikachu.start() 533 | turtle.mainloop() 534 | 535 | 536 | if __name__ == '__main__': 537 | main() 538 | -------------------------------------------------------------------------------- /Source Code/26_sound_recorder.py: -------------------------------------------------------------------------------- 1 | import tkinter as tk 2 | import threading 3 | import pyaudio 4 | import wave 5 | 6 | class App(): 7 | chunk = 1024 8 | sample_format = pyaudio.paInt16 9 | channels = 2 10 | fs = 44100 11 | 12 | frames = [] 13 | def __init__(self, master): 14 | self.isrecording = False 15 | self.button1 = tk.Button(main, text='rec',command=self.startrecording) 16 | self.button2 = tk.Button(main, text='stop',command=self.stoprecording) 17 | self.button1.focus() 18 | 19 | self.button1.pack() 20 | self.button2.pack() 21 | 22 | def startrecording(self): 23 | self.p = pyaudio.PyAudio() 24 | self.stream = self.p.open(format=self.sample_format,channels=self.channels,rate=self.fs,frames_per_buffer=self.chunk,input=True) 25 | self.isrecording = True 26 | 27 | print('Recording') 28 | self.button2.focus() 29 | t = threading.Thread(target=self.record) 30 | t.start() 31 | 32 | def stoprecording(self): 33 | self.isrecording = False 34 | self.variable = tk.StringVar() 35 | self.name = tk.Entry(main, textvariable = self.variable,bg = "pink",width = 15) 36 | self.name.focus() 37 | self.name.pack() 38 | print('recording complete') 39 | 40 | self.button3 = tk.Button(main, text='SAVE',command=self.file_name) 41 | self.button3.pack() 42 | self.button3.focus() 43 | 44 | def file_name(self): 45 | self.filename=self.variable.get() 46 | self.filename = self.filename+".wav" 47 | wf = wave.open(self.filename, 'wb') 48 | wf.setnchannels(self.channels) 49 | wf.setsampwidth(self.p.get_sample_size(self.sample_format)) 50 | wf.setframerate(self.fs) 51 | wf.writeframes(b''.join(self.frames)) 52 | wf.close() 53 | main.destroy() 54 | def record(self): 55 | 56 | while self.isrecording: 57 | data = self.stream.read(self.chunk) 58 | self.frames.append(data) 59 | 60 | main = tk.Tk() 61 | 62 | main.title('Sound Recorder') 63 | main.geometry('200x100') 64 | app = App(main) 65 | main.mainloop() -------------------------------------------------------------------------------- /Source Code/27_autoFollow.py: -------------------------------------------------------------------------------- 1 | # import all nessecery modules 2 | from selenium import webdriver 3 | from selenium.webdriver.common.keys import Keys 4 | from time import sleep 5 | 6 | driver = webdriver.Chrome(executable_path="C:\Drivers\chromedriver.exe") 7 | 8 | # Its Open Instagram in Crome browser 9 | driver.get("https://www.instagram.com/") 10 | sleep(4) 11 | 12 | # Enters your username in username's section 13 | driver.find_element_by_xpath( 14 | "//input[@name=\"username\"]").send_keys("nex_roxx") 15 | # Enters your password in password's section 16 | driver.find_element_by_xpath( 17 | "//input[@name=\"password\"]").send_keys("Passcrack40") 18 | # Clicks Login Button 19 | driver.find_element_by_xpath("//button[@type=\"submit\"]").click() 20 | sleep(3) 21 | 22 | # Clicks on Not Now button on save login info section 23 | driver.find_element_by_xpath("//button[contains(text(),'Not Now')]").click() 24 | sleep(3) 25 | # Clicks on Not Now button on Turns On Notification section 26 | driver.find_element_by_xpath("//button[contains(text(),'Not Now')]").click() 27 | 28 | 29 | # loops for how many followers you wanty to follow (3*5=15) 30 | for i in range(3): 31 | for i in range(5): 32 | driver.find_element_by_xpath('//button[text()="Follow"]').click() 33 | sleep(2) 34 | driver.refresh() 35 | sleep(3) 36 | 37 | driver.close() 38 | -------------------------------------------------------------------------------- /Source Code/28_system_details.py: -------------------------------------------------------------------------------- 1 | import platform 2 | 3 | # displaying OS name 4 | print('system :', platform.system()) 5 | # display node name 6 | print('node :', platform.node()) 7 | # display system’s release 8 | print('release :', platform.release()) 9 | # display system’s release version 10 | print('version :', platform.version()) 11 | # display the machine type 12 | print('machine :', platform.machine()) 13 | # display the (real) processor name 14 | print('processor:', platform.processor()) -------------------------------------------------------------------------------- /Source Code/29_news_notifier.py: -------------------------------------------------------------------------------- 1 | import feedparser 2 | from win10toast import ToastNotifier 3 | 4 | 5 | def parsefeed(): 6 | feed = feedparser.parse("http://feeds.bbci.co.uk/news/rss.xml") 7 | 8 | for news in feed['items']: 9 | ToastNotifier().show_toast(news['title'], news['summary'], duration=15) 10 | 11 | 12 | if __name__ == "__main__": 13 | parsefeed() 14 | -------------------------------------------------------------------------------- /Source Code/30_login_form.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | from tkinter import messagebox 3 | 4 | 5 | def verify_user(): 6 | user = Username_input.get() 7 | passw = password_input.get() 8 | 9 | if user == 'rahul' and passw == 'testcode': 10 | messagebox.showinfo("Success", "Successfully logged In") 11 | else: 12 | messagebox.showerror('Failed', "Invalid Credentials") 13 | 14 | 15 | # Driver Code 16 | if __name__ == "__main__": 17 | # Create root window 18 | root = Tk() 19 | # Change the title 20 | root.title('Login Form') 21 | # Change the window size 22 | root.geometry("400x240") 23 | # no resize for both directions 24 | root.resizable(False, False) 25 | 26 | # set gui widgets 27 | lbl_username = Label(root, text="Username : ", 28 | font=('Helvetica', 12, 'bold')) 29 | lbl_password = Label(root, text="Password : ", 30 | font=('Helvetica', 12, 'bold')) 31 | Username_input = Entry(root, width=20, bd="2", font=( 32 | 'Helvetica', 14), relief=RIDGE) 33 | password_input = Entry(root, width=20, bd="2", font=( 34 | 'Helvetica', 14), show='*', relief=RIDGE) 35 | btn_login = Button(root, text='Login', width=8, 36 | command=verify_user, font=('Helvetica', 14), relief=RIDGE) 37 | 38 | # place geometry 39 | lbl_username.place(x=25, y=30) 40 | lbl_password.place(x=25, y=100) 41 | Username_input.place(x=140, y=30) 42 | password_input.place(x=140, y=100) 43 | btn_login.place(x=160, y=160) 44 | 45 | # start mainloop 46 | root.mainloop() 47 | -------------------------------------------------------------------------------- /Source Code/31_user_authentication_system.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | from tkinter import messagebox 3 | import mysql.connector as my 4 | 5 | 6 | class signup_window: 7 | def __init__(self, root): 8 | self.root = root 9 | self.root.title("Sign Up Window") 10 | self.root.geometry("500x340") 11 | self.root.resizable(False, False) 12 | 13 | lbl_title = Label(self.root, text="SIGN UP FORM", font=( 14 | "helvetica", 16, "bold"), fg="black").place(x=160, y=10) 15 | 16 | # ----------row 1--------- 17 | lbl_fname = Label(self.root, text="First Name", font=( 18 | "helvetica", 12), fg="grey").place(x=20, y=50) 19 | self.txt_fname = Entry(self.root, font=("helvetica", 13), 20 | bg="light grey") 21 | self.txt_fname.place(x=20, y=80, width=180) 22 | 23 | lbl_lname = Label(self.root, text="Last Name", font=( 24 | "helvetica", 12), fg="grey").place(x=250, y=50) 25 | self.txt_lname = Entry(self.root, font=("helvetica", 13), 26 | bg="light grey") 27 | self.txt_lname.place(x=250, y=80, width=180) 28 | 29 | # ----------row 2--------- 30 | lbl_contact = Label(self.root, text="Contact Number", font=( 31 | "helvetica", 12), fg="grey").place(x=20, y=120) 32 | self.txt_contact = Entry(self.root, font=("helvetica", 13), 33 | bg="light grey") 34 | self.txt_contact.place(x=20, y=150, width=180) 35 | 36 | lbl_email = Label(self.root, text="Email", font=( 37 | "helvetica", 12), fg="grey").place(x=250, y=120) 38 | self.txt_email = Entry(self.root, font=("helvetica", 13), 39 | bg="light grey") 40 | self.txt_email.place(x=250, y=150, width=180) 41 | 42 | # ----------row 3--------- 43 | lbl_pass = Label(self.root, text="Password", font=( 44 | "helvetica", 12), fg="grey").place(x=20, y=190) 45 | self.txt_pass = Entry(self.root, font=("helvetica", 13), 46 | bg="light grey", show="*") 47 | self.txt_pass.place(x=20, y=220, width=180) 48 | 49 | lbl_cpass = Label(self.root, text="Confirm Password", font=( 50 | "helvetica", 12), fg="grey").place(x=250, y=190) 51 | self.txt_cpass = Entry(self.root, font=("helvetica", 13), 52 | bg="light grey", show="*") 53 | self.txt_cpass.place(x=250, y=220, width=180) 54 | 55 | # ----------row 4--------- 56 | btn_signup = Button(self.root, text="Sign Up", width=8, command=self.signup, font=( 57 | "helvetica", 13), relief=RIDGE, bd=2, cursor="hand2").place(x=20, y=265) 58 | 59 | lbl_msg = Label(self.root, text="Already, have an account login here ➤ ", font=( 60 | "helvetica", 12)).place(x=110, y=270) 61 | 62 | btn_login = Button(self.root, text="Login", width=8, command=self.login_window, font=( 63 | "helvetica", 13), relief=RIDGE, bd=2, cursor="hand2").place(x=385, y=265) 64 | 65 | def login(self): 66 | if self.txt_email.get() == "" or self.txt_pass.get() == "": 67 | messagebox.showerror( 68 | "error", "All field are required", parent=self.root) 69 | else: 70 | 71 | try: 72 | # connection to the database 73 | con = my.connect(host='localhost', user='root', 74 | password='your password', database='students') 75 | cur = con.cursor() 76 | cur.execute("select * from students where email=%s and password= %s", 77 | (self.txt_email.get(), self.txt_pass.get())) 78 | row = cur.fetchone() 79 | # print(row) 80 | if row == None: 81 | messagebox.showerror( 82 | "error", "INVALID USERNAME AND PASSWORD", parent=self.root) 83 | else: 84 | messagebox.showinfo( 85 | "Success", "Login successfully", parent=self.root) 86 | con.close() 87 | self.clear_login() 88 | except Exception as es: 89 | messagebox.showerror( 90 | "error", f"error due to {es}", parent=self.root) 91 | 92 | def clear_login(self): 93 | self.txt_email.delete(0, END) 94 | self.txt_pass.delete(0, END) 95 | 96 | def login_window(self): 97 | login = Toplevel() 98 | self.root = login 99 | self.root.title("Login Window") 100 | self.root.geometry("400x250") 101 | self.root.resizable(False, False) 102 | 103 | lbl_title = Label(self.root, text="LOGIN HERE", font=( 104 | "helvetica", 16, "bold"), fg="black").place(x=120, y=10) 105 | 106 | lbl_email = Label(self.root, text="Email :", font=( 107 | "helvetica", 14), fg="black").place(x=40, y=70) 108 | self.txt_email = Entry(self.root, font=("helvetica", 12), 109 | bg="light grey") 110 | self.txt_email.place(x=170, y=70, width=190, height=25) 111 | 112 | # ----------row 3--------- 113 | lbl_pass = Label(self.root, text="Password :", font=( 114 | "helvetica", 14), fg="black").place(x=40, y=140) 115 | self.txt_pass = Entry(self.root, font=("helvetica", 14), 116 | bg="light grey", show="*") 117 | self.txt_pass.place(x=170, y=140, width=190) 118 | 119 | btn_login = Button(self.root, text="Login", width=8, font=( 120 | "helvetica", 14), relief=RIDGE, bd=2, command=self.login, cursor="hand2").place(x=160, y=195) 121 | 122 | def clear_signup(self): 123 | self.txt_fname.delete(0, END) 124 | self.txt_lname.delete(0, END) 125 | self.txt_contact.delete(0, END) 126 | self.txt_email.delete(0, END) 127 | self.txt_pass.delete(0, END) 128 | self.txt_cpass.delete(0, END) 129 | 130 | def signup(self): 131 | if self.txt_fname.get() == "" or self.txt_lname.get() == "" or self.txt_email.get() == "" or self.txt_contact.get() == "" or self.txt_pass.get() == "" or self.txt_cpass.get() == "": 132 | messagebox.showerror( 133 | "error", "All field are required", parent=self.root) 134 | elif self.txt_pass.get() != self.txt_cpass.get(): 135 | messagebox.showerror( 136 | "error", "Password didn't matched", parent=self.root) 137 | else: 138 | try: 139 | # connection to the database 140 | con = my.connect(host='localhost', user='root', 141 | password='your password', database='students') 142 | cur = con.cursor() 143 | cur.execute("select * from students where email=%s", 144 | (self.txt_email.get(),)) 145 | row = cur.fetchone() 146 | if row != None: 147 | messagebox.showerror( 148 | "error", "Already User Exists, Try with another email", parent=self.root) 149 | else: 150 | cur.execute( 151 | """insert into students (first_name,last_name,contact_number,email,password) values(%s,%s,%s,%s,%s)""", (self.txt_fname.get(), self.txt_lname.get(), self.txt_contact.get(), self.txt_email.get(), self.txt_pass.get())) 152 | con.commit() 153 | con.close() 154 | messagebox.showinfo( 155 | "Success", "Sign Up successfully", parent=self.root) 156 | self.clear_signup() 157 | except Exception as es: 158 | messagebox.showerror( 159 | "error", f"error due to {es}", parent=self.root) 160 | 161 | 162 | if __name__ == "__main__": 163 | root = Tk() 164 | obj = signup_window(root) 165 | root.mainloop() 166 | -------------------------------------------------------------------------------- /Source Code/32_battery_notifier.py: -------------------------------------------------------------------------------- 1 | import psutil 2 | from plyer import notification 3 | import time 4 | 5 | battery = psutil.sensors_battery() 6 | 7 | while(True): 8 | percent = battery.percent 9 | 10 | notification.notify( 11 | title="Battery Percentage", 12 | message=str(percent)+"% Battery remaining", 13 | timeout=100 14 | ) 15 | # After every 60 min it will show the Battery percentage 16 | time.sleep(60*60) 17 | -------------------------------------------------------------------------------- /Source Code/33_internet_speed.py: -------------------------------------------------------------------------------- 1 | import speedtest 2 | 3 | st = speedtest.Speedtest() 4 | option = int(input('''What speed do you want to test: 5 | 6 | 1) Download Speed 7 | 8 | 2) Upload Speed 9 | 10 | 3) Ping 11 | 12 | Your Choice: ''')) 13 | 14 | 15 | if option == 1: 16 | 17 | print(st.download()) 18 | 19 | elif option == 2: 20 | 21 | print(st.upload()) 22 | 23 | elif option == 3: 24 | 25 | servernames =[] 26 | 27 | st.get_servers(servernames) 28 | 29 | print(st.results.ping) 30 | 31 | else: 32 | 33 | print("Please enter the correct choice !") -------------------------------------------------------------------------------- /Source Code/34_docx_to_pdf.py: -------------------------------------------------------------------------------- 1 | # Import the convert method from the 2 | # docx2pdf module 3 | from docx2pdf import convert 4 | 5 | # Converting docx present in the same folder 6 | # as the python file 7 | convert("intro.docx") 8 | -------------------------------------------------------------------------------- /Source Code/35_barcode_generator.py: -------------------------------------------------------------------------------- 1 | # import EAN13 from barcode module 2 | from barcode import EAN13 3 | 4 | # import ImageWriter to generate an image file 5 | from barcode.writer import ImageWriter 6 | 7 | 8 | def generate_barcode(num): 9 | # Now, let's create an object of EAN13 class and 10 | # pass the number with the ImageWriter() as the writer 11 | my_code = EAN13(num, writer=ImageWriter()) 12 | 13 | # Our barcode is ready. Let's save it. 14 | my_code.save("bar_code1") 15 | 16 | 17 | if __name__ == "__main__": 18 | generate_barcode(input("Enter 12 Digit Number to generate Bar Code : ")) 19 | -------------------------------------------------------------------------------- /Source Code/36_captcha_generator.py: -------------------------------------------------------------------------------- 1 | # Generate Random Captcha In Python 2 | 3 | # import required modules 4 | from captcha.image import ImageCaptcha 5 | from captcha.audio import AudioCaptcha 6 | import random 7 | 8 | # Create an instance of ImageCaptcha. 9 | img = ImageCaptcha() 10 | # Create an instance of AudioCaptcha. 11 | audio = AudioCaptcha() 12 | 13 | # generate rand string of number 14 | rand = str(random.randint(10000, 99999)) 15 | 16 | # Call img.generate method to create the image object 17 | img.generate(rand) 18 | # Call img.write method to save the image to a file. 19 | img.write(rand, 'cap.png') 20 | 21 | # Generate autio captcha data 22 | audio.generate(rand) 23 | # Save the audio captcha data into a audio file. 24 | audio.write(rand, 'aud.wav') 25 | -------------------------------------------------------------------------------- /Source Code/37_cartoonify_image.py: -------------------------------------------------------------------------------- 1 | # import libraries 2 | import cv2 3 | import numpy as np 4 | 5 | # load Image 6 | img = cv2.imread("demo.jpg") 7 | 8 | # Create Edge Mask 9 | gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 10 | gray_blur = cv2.medianBlur(gray, 5) 11 | # detect and enhance edges 12 | edges = cv2.adaptiveThreshold( 13 | gray_blur, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 9, 9) 14 | 15 | # color quantization 16 | # cartoonization 17 | color = cv2.bilateralFilter(img, 8, 250, 250) 18 | cartoon = cv2.bitwise_and(color, color, mask=edges) 19 | 20 | # show output image 21 | cv2.imshow("Image", img) 22 | cv2.imshow("Cartoon", cartoon) 23 | cv2.waitKey(0) 24 | cv2.destroyAllWindows() 25 | -------------------------------------------------------------------------------- /Source Code/38_sketch_img.py: -------------------------------------------------------------------------------- 1 | # Import required libraries 2 | import cv2 3 | 4 | # Load the image 5 | filename = 'iron.jpg' 6 | img = cv2.imread(filename) 7 | 8 | # Convert image into gray_scale image 9 | gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 10 | 11 | # Invert the image 12 | inverted_gray_img = cv2.bitwise_not(gray_img) 13 | 14 | # convert inverted image into a blur image 15 | blurred_img = cv2.GaussianBlur(inverted_gray_img, (21, 21), 0) 16 | 17 | # Inverting the image the blurred image 18 | inverted_blurred_img = cv2.bitwise_not(blurred_img) 19 | 20 | #Final Output as Pencil Sketch 21 | pencil_sketch_IMG = cv2.divide(gray_img, inverted_blurred_img, scale=256.0) 22 | 23 | # Save the image 24 | cv2.imwrite('sketch.png', pencil_sketch_IMG) 25 | -------------------------------------------------------------------------------- /Source Code/39_pdf_to_docx.py: -------------------------------------------------------------------------------- 1 | from pdf2docx import Converter 2 | 3 | # enter your pdf name 4 | pdf_file = 'ang.pdf' 5 | # docs file to be created 6 | docx_file = 'main.docx' 7 | 8 | # convert pdf to docx 9 | cv = Converter(pdf_file) 10 | cv.convert(docx_file, start=0, end=None) 11 | cv.close() 12 | -------------------------------------------------------------------------------- /Source Code/tax/MainWindow.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'mainwindow.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.12.2 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | from PyQt5 import QtCore, QtGui, QtWidgets 10 | 11 | 12 | class Ui_MainWindow(object): 13 | def setupUi(self, MainWindow): 14 | MainWindow.setObjectName("MainWindow") 15 | MainWindow.resize(328, 273) 16 | self.centralwidget = QtWidgets.QWidget(MainWindow) 17 | self.centralwidget.setObjectName("centralwidget") 18 | self.formLayout = QtWidgets.QFormLayout(self.centralwidget) 19 | self.formLayout.setObjectName("formLayout") 20 | self.label_3 = QtWidgets.QLabel(self.centralwidget) 21 | font = QtGui.QFont() 22 | font.setPointSize(28) 23 | font.setBold(True) 24 | font.setWeight(75) 25 | self.label_3.setFont(font) 26 | self.label_3.setObjectName("label_3") 27 | self.formLayout.setWidget(0, QtWidgets.QFormLayout.SpanningRole, self.label_3) 28 | self.label = QtWidgets.QLabel(self.centralwidget) 29 | font = QtGui.QFont() 30 | font.setPointSize(15) 31 | self.label.setFont(font) 32 | self.label.setObjectName("label") 33 | self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.label) 34 | self.price_box = QtWidgets.QLineEdit(self.centralwidget) 35 | self.price_box.setObjectName("price_box") 36 | self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.price_box) 37 | self.tax_rate = QtWidgets.QSpinBox(self.centralwidget) 38 | self.tax_rate.setProperty("value", 20) 39 | self.tax_rate.setObjectName("tax_rate") 40 | self.formLayout.setWidget(5, QtWidgets.QFormLayout.FieldRole, self.tax_rate) 41 | self.calc_tax_button = QtWidgets.QPushButton(self.centralwidget) 42 | self.calc_tax_button.setObjectName("calc_tax_button") 43 | self.formLayout.setWidget(6, QtWidgets.QFormLayout.FieldRole, self.calc_tax_button) 44 | self.results_output = QtWidgets.QLabel(self.centralwidget) 45 | self.results_output.setText("") 46 | self.results_output.setObjectName("results_output") 47 | self.formLayout.setWidget(8, QtWidgets.QFormLayout.SpanningRole, self.results_output) 48 | self.label_2 = QtWidgets.QLabel(self.centralwidget) 49 | self.label_2.setObjectName("label_2") 50 | self.formLayout.setWidget(5, QtWidgets.QFormLayout.LabelRole, self.label_2) 51 | MainWindow.setCentralWidget(self.centralwidget) 52 | self.menubar = QtWidgets.QMenuBar(MainWindow) 53 | self.menubar.setGeometry(QtCore.QRect(-100, -100, 328, 22)) 54 | self.menubar.setObjectName("menubar") 55 | MainWindow.setMenuBar(self.menubar) 56 | self.statusbar = QtWidgets.QStatusBar(MainWindow) 57 | self.statusbar.setObjectName("statusbar") 58 | MainWindow.setStatusBar(self.statusbar) 59 | 60 | self.retranslateUi(MainWindow) 61 | QtCore.QMetaObject.connectSlotsByName(MainWindow) 62 | 63 | def retranslateUi(self, MainWindow): 64 | _translate = QtCore.QCoreApplication.translate 65 | MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) 66 | self.label_3.setText(_translate("MainWindow", "Sales Tax Calculator")) 67 | self.label.setText(_translate("MainWindow", "Price")) 68 | self.calc_tax_button.setText(_translate("MainWindow", "Calculate Tax")) 69 | self.label_2.setText(_translate("MainWindow", "Tax Rate %")) -------------------------------------------------------------------------------- /Source Code/tax/README.md: -------------------------------------------------------------------------------- 1 | Required Modules - 2 | 1. Pyqt5 #pip install PyQt5 3 | 2. Pyqt5Designer #pip install PyQt5Designer -------------------------------------------------------------------------------- /Source Code/tax/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 328 10 | 273 11 | 12 | 13 | 14 | Sales Tax Calulator 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 28 23 | 75 24 | true 25 | 26 | 27 | 28 | Sales Tax Calculator 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 15 37 | 38 | 39 | 40 | Price 41 | 42 | 43 | 44 | 45 | 46 | 47 | Qt::ImhNone 48 | 49 | 50 | Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter 51 | 52 | 53 | 54 | 55 | 56 | 57 | 20 58 | 59 | 60 | 61 | 62 | 63 | 64 | Calculate Tax 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | Tax Rate % 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 0 88 | 0 89 | 328 90 | 22 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /Source Code/tax/tax.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from decimal import Decimal 3 | 4 | from PyQt5 import QtCore, QtGui, QtWidgets, uic 5 | 6 | 7 | qtCreatorFile = "mainwindow.ui" # Enter file here. 8 | Ui_MainWindow, QtBaseClass = uic.loadUiType(qtCreatorFile) 9 | 10 | 11 | class MyWindow(QtWidgets.QMainWindow, Ui_MainWindow): 12 | def __init__(self): 13 | QtWidgets.QMainWindow.__init__(self) 14 | Ui_MainWindow.__init__(self) 15 | self.setupUi(self) 16 | self.calc_tax_button.clicked.connect(self.calculate_tax) 17 | 18 | def calculate_tax(self): 19 | price = Decimal(self.price_box.text()) 20 | tax = Decimal(self.tax_rate.value()) 21 | total_price = price + ((tax / 100) * price) 22 | total_price_string = "The total price with tax is: {:.2f}".format(total_price) 23 | self.results_output.setText(total_price_string) 24 | 25 | 26 | if __name__ == "__main__": 27 | app = QtWidgets.QApplication(sys.argv) 28 | window = MyWindow() 29 | window.show() 30 | sys.exit(app.exec_()) 31 | --------------------------------------------------------------------------------