Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jun 29, 2024. It is now read-only.

Commit 63a74a7

Browse files
Add files via upload
1 parent b5be041 commit 63a74a7

File tree

4 files changed

+156
-0
lines changed

4 files changed

+156
-0
lines changed

‎guess.py‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import random
2+
def random_number():
3+
x=random.randint(1,100)
4+
print(f"The computer generated number is{x}")
5+
print("computer choose a number!!!")
6+
print("ARE YOU READY TO GUESS THE NUMBER!!")
7+
max=4
8+
min=0
9+
print("let's start the game")
10+
print(f"choose a number between (1 to100)\n NOTE:you will have {max} attempts to guess the number")
11+
while min<max :
12+
guess=int(input("enter the number:"))
13+
min=min+1
14+
if guess<x:
15+
print(f"The value you guessed is less than the computer generated number, you lost {min} chances,Try again!!")
16+
elif guess>x:
17+
print(f"The value is greater than the computer generated number you lost {min} chances,Try again!!")
18+
else:
19+
print("congrats you guessed the number correctly!!")
20+
print(f"You took {min} attempts")
21+
return
22+
print("You've run out of attempts!")
23+
random_number()

‎list1.py‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import json
2+
import os
3+
def display_menu():
4+
print("Todo List Menu:")
5+
print("1. Add task")
6+
print("2. Remove task")
7+
print("3. View tasks")
8+
print("4. Exit")
9+
def todolist():
10+
tasks = []
11+
12+
while 1:
13+
display_menu()
14+
ch= input("Enter your choice btw 1 and 4: ")
15+
16+
if ch== "1":
17+
task = input("Enter a new task: ")
18+
tasks.append(task)
19+
print("Task added.")
20+
21+
elif ch == "2":
22+
task = input("Enter the task to remove: ")
23+
24+
if task in tasks:
25+
tasks.remove(task)
26+
print("Task removed.")
27+
else:
28+
print("Task not found.")
29+
30+
31+
elif ch== "3":
32+
print("Tasks are:")
33+
if tasks:
34+
for index ,task in enumerate(tasks,start=1):
35+
print(f"{index}. {task}")
36+
else:
37+
print("no tasks added")
38+
elif ch == "4":
39+
break
40+
41+
else:
42+
print("Invalid choice. Please try again.")
43+
todolist()

‎pdf.py‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import PyPDF2
2+
import fitz # PyMuPDF
3+
from docx import Document
4+
from PIL import Image
5+
from docx.shared import Pt
6+
from docx.enum.text import WD_PARAGRAPH_ALIGNMENT
7+
8+
def pdf_to_image(pdf_path, image_path):
9+
pdf_document = fitz.open(pdf_path)
10+
for page_number in range(len(pdf_document)):
11+
page = pdf_document[page_number]
12+
image = page.get_pixmap()
13+
image.save(f"{image_path}_page_{page_number + 1}.png")
14+
15+
def pdf_to_text(pdf_path, text_path):
16+
with open(pdf_path, 'rb') as file:
17+
reader = PyPDF2.PdfReader(file)
18+
text = ''
19+
for page_number in range(len(reader.pages)):
20+
text += reader.pages[page_number].extract_text()
21+
22+
with open(text_path, 'w', encoding='utf-8') as text_file:
23+
text_file.write(text)
24+
25+
def text_to_document(text_path, doc_path):
26+
document = Document()
27+
with open(text_path, 'r', encoding='utf-8') as text_file:
28+
for line in text_file:
29+
paragraph = document.add_paragraph(line.strip())
30+
paragraph.alignment = WD_PARAGRAPH_ALIGNMENT.LEFT
31+
run = paragraph.runs[0]
32+
run.font.size = Pt(12) # Set font size to 12pt (adjust as needed)
33+
# You can add more formatting options here
34+
35+
document.save(doc_path)
36+
37+
# Example usage
38+
pdf_file = r"C:\Users\Acer\Downloads\Resume.pdf"
39+
image_output_path =r"C:\Users\Acer\Downloads"
40+
text_path=r"C:\Users\Acer\Downloads\textfile.txt"
41+
42+
doc_output_path =r"C:\Users\Acer\Downloads\document.docx"
43+
44+
pdf_to_image(pdf_file, image_output_path)
45+
pdf_to_text(pdf_file, text_path)
46+
text_to_document(text_path, doc_output_path)

‎simplecal.py‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
def calculator():
2+
while True:
3+
# Print options for the user
4+
print("Enter '+' to add two numbers")
5+
print("Enter '-' to subtract two numbers")
6+
print("Enter '*' to multiply two numbers")
7+
print("Enter '/' to divide two numbers")
8+
print("Enter 'quit' to end the program")
9+
10+
# Get user input
11+
user_input = input("enter your operator: ")
12+
13+
# Check if the user wants to quit
14+
if user_input == "quit":
15+
break
16+
# Check if the user input is a valid operator
17+
elif user_input in ["+", "-", "*", "/"]:
18+
# Get first number
19+
num1 = float(input("Enter a number: "))
20+
# Get second number
21+
num2 = float(input("Enter another number: "))
22+
23+
# Perform the operation based on the user input
24+
if user_input == "+":
25+
result = num1 + num2
26+
print(num1, "+", num2, "=", result)
27+
28+
elif user_input == "-":
29+
result = num1 - num2
30+
print(num1, "-", num2, "=", result)
31+
32+
elif user_input == "*":
33+
result = num1 * num2
34+
print(num1, "*", num2, "=", result)
35+
36+
elif user_input == "/":
37+
result = num1 / num2
38+
print(num1, "/", num2, "=", result)
39+
else:
40+
# In case of invalid input
41+
print("Invalid Input")
42+
43+
# Call the calculator function to start the program
44+
calculator()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /