diff --git a/Pypde.py b/Pypde.py new file mode 100644 index 0000000..146fc70 --- /dev/null +++ b/Pypde.py @@ -0,0 +1,46 @@ +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\Acer\Downloads\Resume.pdf" +image_output_path =r"C:\Users\Acer\Downloads" +text_path=r"C:\Users\Acer\Downloads\textfile.txt" + +doc_output_path =r"C:\Users\Acer\Downloads\document.docx" + +pdf_to_image(pdf_file, image_output_path) +pdf_to_text(pdf_file, text_path) +text_to_document(text_path, doc_output_path) \ No newline at end of file diff --git a/calculator.py b/calculator.py new file mode 100644 index 0000000..71b52fa --- /dev/null +++ b/calculator.py @@ -0,0 +1,45 @@ + +def calculator(): + while True: + # Print options for the user + print("Enter '+' to add two numbers") + print("Enter '-' to subtract two numbers") + print("Enter '*' to multiply two numbers") + print("Enter '/' to divide two numbers") + print("Enter 'quit' to end the program") + + # Get user input + user_input = input("enter your operator: ") + + # Check if the user wants to quit + if user_input == "quit": + break + # Check if the user input is a valid operator + elif user_input in ["+", "-", "*", "/"]: + # Get first number + num1 = float(input("Enter a number: ")) + # Get second number + num2 = float(input("Enter another number: ")) + + # Perform the operation based on the user input + if user_input == "+": + result = num1 + num2 + print(num1, "+", num2, "=", result) + + elif user_input == "-": + result = num1 - num2 + print(num1, "-", num2, "=", result) + + elif user_input == "*": + result = num1 * num2 + print(num1, "*", num2, "=", result) + + elif user_input == "/": + result = num1 / num2 + print(num1, "/", num2, "=", result) + else: + # In case of invalid input + print("Invalid Input") + +# Call the calculator function to start the program +calculator() \ No newline at end of file diff --git a/json.py b/json.py new file mode 100644 index 0000000..c7d83ce --- /dev/null +++ b/json.py @@ -0,0 +1,43 @@ +import json +import os +def display_menu(): + print("Todo List Menu:") + print("1. Add task") + print("2. Remove task") + print("3. View tasks") + print("4. Exit") +def todolist(): + tasks = [] + + while 1: + display_menu() + ch= input("Enter your choice btw 1 and 4: ") + + if ch== "1": + task = input("Enter a new task: ") + tasks.append(task) + print("Task added.") + + elif ch == "2": + task = input("Enter the task to remove: ") + + if task in tasks: + tasks.remove(task) + print("Task removed.") + else: + print("Task not found.") + + + elif ch== "3": + print("Tasks are:") + if tasks: + for index ,task in enumerate(tasks,start=1): + print(f"{index}. {task}") + else: + print("no tasks added") + elif ch == "4": + break + + else: + print("Invalid choice. Please try again.") +todolist() \ No newline at end of file diff --git a/uess.py b/uess.py new file mode 100644 index 0000000..e06a0f3 --- /dev/null +++ b/uess.py @@ -0,0 +1,24 @@ + +import random +def random_number(): + x=random.randint(1,100) + print(f"The computer generated number is{x}") + print("computer choose a number!!!") + print("ARE YOU READY TO GUESS THE NUMBER!!") + max=4 + min=0 + print("let's start the game") + print(f"choose a number between (1 to100)\n NOTE:you will have {max} attempts to guess the number") + while minx: + print(f"The value is greater than the computer generated number you lost {min} chances,Try again!!") + else: + print("congrats you guessed the number correctly!!") + print(f"You took {min} attempts") + return + print("You've run out of attempts!") +random_number() \ No newline at end of file