Skip to content
This repository was archived by the owner on Jun 29, 2024. It is now read-only.

Add files via upload #71

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions Pypde.py
Original file line number Diff line number Diff line change
@@ -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)
45 changes: 45 additions & 0 deletions calculator.py
Original file line number Diff line number Diff line change
@@ -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()
43 changes: 43 additions & 0 deletions json.py
Original file line number Diff line number Diff line change
@@ -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()
24 changes: 24 additions & 0 deletions uess.py
Original file line number Diff line number Diff line change
@@ -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 min<max :
guess=int(input("enter the number:"))
min=min+1
if guess<x:
print(f"The value you guessed is less than the computer generated number, you lost {min} chances,Try again!!")
elif guess>x:
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()