From c952915905fca057a9436af8be094acfb48ff186 Mon Sep 17 00:00:00 2001 From: Junuthulakavya <167897707+Junuthulakavya@users.noreply.github.com> Date: Sat, 11 May 2024 07:12:26 +0530 Subject: [PATCH 1/3] Add files via upload --- Guessing_number_game.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Guessing_number_game.py diff --git a/Guessing_number_game.py b/Guessing_number_game.py new file mode 100644 index 0000000..b06f3a3 --- /dev/null +++ b/Guessing_number_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 Date: Sat, 11 May 2024 07:49:19 +0530 Subject: [PATCH 2/3] 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 39005a1687f691e106396d42bbd77ac64f8d4518 Mon Sep 17 00:00:00 2001 From: Junuthulakavya <167897707+Junuthulakavya@users.noreply.github.com> Date: Wed, 15 May 2024 08:47:16 +0530 Subject: [PATCH 3/3] 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)