From 34ac562bc0dd9041e0543b329a4100d5b6c4d71a Mon Sep 17 00:00:00 2001 From: Junuthulakavya <167897707+Junuthulakavya@users.noreply.github.com> Date: Wed, 15 May 2024 09:09:07 +0530 Subject: [PATCH 1/4] Add files via upload --- simple_calculator.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 simple_calculator.py diff --git a/simple_calculator.py b/simple_calculator.py new file mode 100644 index 0000000..978f097 --- /dev/null +++ b/simple_calculator.py @@ -0,0 +1,37 @@ +def add(x,y): + return x+y +def sub(x,y): + return x-y +def mul(x,y): + return x*y +def div(x,y): + return x/y +def moddiv(x,y): + return x%y +print("ENTER 1.ADDITION \n\n 2.SUBTRACTION \n\n 3.MULTIPLICATION \n\n 4.DIVISION \n\n 5.MODULUS_DIVISION\n\n 6.EXIT\n\n") +#ch=int(input("Enter Your Choice:")) +n=int(input("enter no of operations you want to do:").upper()) +for i in range(1,n+1): + ch=int(input("Enter Your Choice:")) + if ch==1: + x=int(input("enter x value:").capitalize()) + y=int(input("enter x value:").capitalize()) + print("THE SUM OF",x,"AND",y,"IS",add(x,y)) + elif ch==2: + x=int(input("enter x value:").capitalize()) + y=int(input("enter x value:").capitalize()) + print("THE SUBTRACTION OF",x,"AND",y,"IS",sub(x,y)) + elif ch==3: + x=int(input("enter x value:").capitalize()) + y=int(input("enter x value:").capitalize()) + print("THE MULTIPLICATION OF",x,"AND",y,"IS",mul(x,y)) + elif ch==4: + x=int(input("enter x value:").capitalize()) + y=int(input("enter x value:").capitalize()) + print("THE DIVISION OF",x,"BY",y,"IS",div(x,y)) + elif ch==5: + x=int(input("enter x value:").capitalize()) + y=int(input("enter x value:").capitalize()) + print("THE MODDIVISON OF",x,"AND",y,"IS",moddiv(x,y)) + else: + exit() \ No newline at end of file From 459410d6e04487ce990e3f2184789f53ca475db5 Mon Sep 17 00:00:00 2001 From: Junuthulakavya <167897707+Junuthulakavya@users.noreply.github.com> Date: Wed, 15 May 2024 09:09:38 +0530 Subject: [PATCH 2/4] Add files via upload --- Number_guessing_game.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Number_guessing_game.py diff --git a/Number_guessing_game.py b/Number_guessing_game.py new file mode 100644 index 0000000..b06f3a3 --- /dev/null +++ b/Number_guessing_game.py @@ -0,0 +1,34 @@ +import random as rd +s="*"*10 +i=1 +print(s,"welcome to number guessing game",s) +print("computer is ready to choose a number") +C=rd.randint(1,100) + +print("Are you ready to guess that number") +print("if yes \n Enter 1 \n if No \n Enter 2") +x=int(input()) +if x==1: + print("NOTE: you have only 5 chances to guess the number") + print("ALL THE BEST!!!") + while i<=5: + y=int(input("enter your number")) + if C==y: + print(s,"Hurray!!! you got the number",s) + i==5 + elif C>y: + print("You guessed a number which is less than the Computer number") + i+=1 + elif C<y: + print("You guessed a number which is greater than the Computer number") + i+=1 + else: + print("Entered a number which is out the range!!!") + print("THE RANGE OF THE NUMBERS TO GUESS IS FROM 1 TO 100") + i+=1 + + else: + print("you reached your maximum limit!!!") + print("The number generated by the computer is",C) +else: + print("We will play next time!!\n\n THANK YOU!!!") \ No newline at end of file From 2812e4861253d26ffb51db8773aa4e10bc54dcb5 Mon Sep 17 00:00:00 2001 From: Junuthulakavya <167897707+Junuthulakavya@users.noreply.github.com> Date: Wed, 15 May 2024 09:10:11 +0530 Subject: [PATCH 3/4] Add files via upload --- To-Do_List.py | 207 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 207 insertions(+) create mode 100644 To-Do_List.py diff --git a/To-Do_List.py b/To-Do_List.py new file mode 100644 index 0000000..498da81 --- /dev/null +++ b/To-Do_List.py @@ -0,0 +1,207 @@ +import tkinter as tk # importing the tkinter module as tk +from tkinter import ttk # importing the ttk module from the tkinter library +from tkinter import messagebox # importing the messagebox module from the tkinter library +import sqlite3 as sql # importing the sqlite3 module as sql + +# defining the function to add tasks to the list +def add_task(): + # getting the string from the entry field + task_string = task_field.get() + # checking whether the string is empty or not + if len(task_string) == 0: + # displaying a message box with 'Empty Field' message + messagebox.showinfo('Error', 'Field is Empty.') + else: + # adding the string to the tasks list + tasks.append(task_string) + # using the execute() method to execute a SQL statement + the_cursor.execute('insert into tasks values (?)', (task_string ,)) + # calling the function to update the list + list_update() + # deleting the entry in the entry field + task_field.delete(0, 'end') + +# defining the function to update the list +def list_update(): + # calling the function to clear the list + clear_list() + # iterating through the strings in the list + for task in tasks: + # using the insert() method to insert the tasks in the list box + task_listbox.insert('end', task) + +# defining the function to delete a task from the list +def delete_task(): + # using the try-except method + try: + # getting the selected entry from the list box + the_value = task_listbox.get(task_listbox.curselection()) + # checking if the stored value is present in the tasks list + if the_value in tasks: + # removing the task from the list + tasks.remove(the_value) + # calling the function to update the list + list_update() + # using the execute() method to execute a SQL statement + the_cursor.execute('delete from tasks where title = ?', (the_value,)) + except: + # displaying the message box with 'No Item Selected' message for an exception + messagebox.showinfo('Error', 'No Task Selected. Cannot Delete.') + +# function to delete all tasks from the list +def delete_all_tasks(): + # displaying a message box to ask user for confirmation + message_box = messagebox.askyesno('Delete All', 'Are you sure?') + # if the value turns to be True + if message_box == True: + # using while loop to iterate through the tasks list until it's empty + while(len(tasks) != 0): + # using the pop() method to pop out the elements from the list + tasks.pop() + # using the execute() method to execute a SQL statement + the_cursor.execute('delete from tasks') + # calling the function to update the list + list_update() + +# function to clear the list +def clear_list(): + # using the delete method to delete all entries from the list box + task_listbox.delete(0, 'end') + +# function to close the application +def close(): + # printing the elements from the tasks list + print(tasks) + # using the destroy() method to close the application + guiWindow.destroy() + +# function to retrieve data from the database +def retrieve_database(): + # using the while loop to iterate through the elements in the tasks list + while(len(tasks) != 0): + # using the pop() method to pop out the elements from the list + tasks.pop() + # iterating through the rows in the database table + for row in the_cursor.execute('select title from tasks'): + # using the append() method to insert the titles from the table in the list + tasks.append(row[0]) + +# main function +if __name__ == "__main__": + # creating an object of the Tk() class + guiWindow = tk.Tk() + # setting the title of the window + guiWindow.title("To-Do List Manager - CSEDGE") + # setting the geometry of the window + guiWindow.geometry("500x450+750+250") + # disabling the resizable option + guiWindow.resizable(0, 0) + # setting the background color to #FAEBD7 + guiWindow.configure(bg = "#FAEBD7") + + # using the connect() method to connect to the database + the_connection = sql.connect('listOfTasks.db') + # creating the cursor object of the cursor class + the_cursor = the_connection.cursor() + # using the execute() method to execute a SQL statement + the_cursor.execute('create table if not exists tasks (title text)') + + # defining an empty list + tasks = [] + + # defining frames using the tk.Frame() widget + header_frame = tk.Frame(guiWindow, bg = "#FAEBD7") + functions_frame = tk.Frame(guiWindow, bg = "#FAEBD7") + listbox_frame = tk.Frame(guiWindow, bg = "#FAEBD7") + + # using the pack() method to place the frames in the application + header_frame.pack(fill = "both") + functions_frame.pack(side = "left", expand = True, fill = "both") + listbox_frame.pack(side = "right", expand = True, fill = "both") + + # defining a label using the ttk.Label() widget + header_label = ttk.Label( + header_frame, + text = "The To-Do List", + font = ("Brush Script MT", "30"), + background = "#FAEBD7", + foreground = "#8B4513" + ) + # using the pack() method to place the label in the application + header_label.pack(padx = 20, pady = 20) + + # defining another label using the ttk.Label() widget + task_label = ttk.Label( + functions_frame, + text = "Enter the Task:", + font = ("Consolas", "11", "bold"), + background = "#FAEBD7", + foreground = "#000000" + ) + # using the place() method to place the label in the application + task_label.place(x = 30, y = 40) + + # defining an entry field using the ttk.Entry() widget + task_field = ttk.Entry( + functions_frame, + font = ("Consolas", "12"), + width = 18, + background = "#FFF8DC", + foreground = "#A52A2A" + ) + # using the place() method to place the entry field in the application + task_field.place(x = 30, y = 80) + + # adding buttons to the application using the ttk.Button() widget + add_button = ttk.Button( + functions_frame, + text = "Add Task YOU WANT TO DO", + width = 24, + command = add_task + ) + del_button = ttk.Button( + functions_frame, + text = "Delete Task Which you have completed", + width = 24, + command = delete_task + ) + del_all_button = ttk.Button( + functions_frame, + text = "Delete All Tasks", + width = 24, + command = delete_all_tasks + ) + exit_button = ttk.Button( + functions_frame, + text = "Exit", + width = 24, + command = close + ) + # using the place() method to set the position of the buttons in the application + add_button.place(x = 30, y = 120) + del_button.place(x = 30, y = 140) + del_all_button.place(x = 30, y = 160) + exit_button.place(x = 30, y = 180) + + # defining a list box using the tk.Listbox() widget + task_listbox = tk.Listbox( + listbox_frame, + width = 46, + height = 20, + selectmode = 'SINGLE', + background = "#FFFFFF", + foreground = "#000000", + selectbackground = "#CD853F", + selectforeground = "#FFFFFF" + ) + # using the place() method to place the list box in the application + task_listbox.place(x = 10, y = 20) + + # calling some functions + retrieve_database() + list_update() + # using the mainloop() method to run the application + guiWindow.mainloop() + # establishing the connection with database + the_connection.commit() + the_cursor.close() \ No newline at end of file From 78200c82a85b8c57f400d60c9239d3878f2d42e1 Mon Sep 17 00:00:00 2001 From: Junuthulakavya <167897707+Junuthulakavya@users.noreply.github.com> Date: Wed, 15 May 2024 09:10:40 +0530 Subject: [PATCH 4/4] Add files via upload --- PDF_TO_DIFFERENT_FORMATS_CONVERTER.py | 45 +++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 PDF_TO_DIFFERENT_FORMATS_CONVERTER.py diff --git a/PDF_TO_DIFFERENT_FORMATS_CONVERTER.py b/PDF_TO_DIFFERENT_FORMATS_CONVERTER.py new file mode 100644 index 0000000..8a7eafa --- /dev/null +++ b/PDF_TO_DIFFERENT_FORMATS_CONVERTER.py @@ -0,0 +1,45 @@ +import PyPDF2 +import fitz # PyMuPDF +from docx import Document +from PIL import Image +from docx.shared import Pt +from docx.enum.text import WD_PARAGRAPH_ALIGNMENT + +def pdf_to_image(pdf_path, image_path): + pdf_document = fitz.open(pdf_path) + for page_number in range(len(pdf_document)): + page = pdf_document[page_number] + image = page.get_pixmap() + image.save(f"{image_path}_page_{page_number + 1}.png") + +def pdf_to_text(pdf_path, text_path): + with open(pdf_path, 'rb') as file: + reader = PyPDF2.PdfReader(file) + text = '' + for page_number in range(len(reader.pages)): + text += reader.pages[page_number].extract_text() + + with open(text_path, 'w', encoding='utf-8') as text_file: + text_file.write(text) + +def text_to_document(text_path, doc_path): + document = Document() + with open(text_path, 'r', encoding='utf-8') as text_file: + for line in text_file: + paragraph = document.add_paragraph(line.strip()) + paragraph.alignment = WD_PARAGRAPH_ALIGNMENT.LEFT + run = paragraph.runs[0] + run.font.size = Pt(12) # Set font size to 12pt (adjust as needed) + # You can add more formatting options here + + document.save(doc_path) + +# Example usage +pdf_file = r"C:\Users\DELL\Downloads\kavya junuthula (3).pdf" +image_output_path =r"C:\Users\DELL\Downloads" +text_output_path=r"C:\Users\DELL\textfile.txt" +doc_output_path =r"C:\Users\DELL\document.docx" + +pdf_to_image(pdf_file, image_output_path) +pdf_to_text(pdf_file, text_output_path) +text_to_document(text_output_path, doc_output_path)