Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/pip/projects/movie-rater/urllib3-…
Browse files Browse the repository at this point in the history
…2.0.6
  • Loading branch information
Mrinank-Bhowmick authored Dec 26, 2023
2 parents 7c876da + 2cf6d6f commit 6b4342f
Show file tree
Hide file tree
Showing 173 changed files with 23,711 additions and 842 deletions.
518 changes: 424 additions & 94 deletions README.md

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions projects/AWS_s3_upload/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import boto3
from botocore.exceptions import NoCredentialsError

ACCESS_KEY = ""
SECRET_KEY = ""
LOCAL_FILE = "local_file_name"
BUCKET_NAME = "bucket_name"
S3_FILE_NAME = "file_name_on_s3"


def upload_to_s3(local_file, bucket, s3_file):
## This function is responsible for uploading the file into the S3 bucket using the specified credentials.
s3 = boto3.client(
"s3", aws_access_key_id=ACCESS_KEY, aws_secret_access_key=SECRET_KEY
)
try:
s3.upload_file(local_file, bucket, s3_file)
print("Upload Successful")
return True
except FileNotFoundError:
print("The file was not found")
return False
except NoCredentialsError:
print("Credentials not available")
return False


result = upload_to_s3(LOCAL_FILE, BUCKET_NAME, S3_FILE_NAME)
13 changes: 13 additions & 0 deletions projects/AWS_s3_upload/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

## Simple Python script for AWS S3 file upload.

### Prerequisites
boto3 (pip install boto3) <br />

### How to run the script
- Specify both ACCESS_KEY and SECRET_KEY. You can get them both on your AWS account in "My Security Credentials" section. <br />
- Specify the local file name, bucket name and the name that you want the file to have inside s3 bucket using LOCAL_FILE, BUCKET_NAME and S3_FILE_NAME variables. <br />
- Run "python main.py" <br />

### Author Name
Yashvardhan Singh https://github.com/pythonicboat
2 changes: 2 additions & 0 deletions projects/AWS_s3_upload/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
boto3==1.20.4
botocore==1.23.4
32 changes: 32 additions & 0 deletions projects/Amazon Product Availbility Checker/amazon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import requests
from bs4 import BeautifulSoup


def check_amazon_availability(product_url):
headers = {
"User-Agent": "Your User Agent Here" # You can set a user agent string here
}

try:
response = requests.get(product_url, headers=headers)
response.raise_for_status()

soup = BeautifulSoup(response.content, "html.parser")

title = soup.find("span", {"id": "productTitle"}).get_text(strip=True)
availability = soup.find(
"span", {"class": "a-declarative", "data-asin": True}
).get_text(strip=True)

if "out of stock" in availability.lower():
print(f"{title} is currently out of stock on Amazon.")
else:
print(f"{title} is available on Amazon.")

except requests.exceptions.RequestException as e:
print("Error:", e)


if __name__ == "__main__":
product_url = "YOUR_PRODUCT_URL_HERE"
check_amazon_availability(product_url)
51 changes: 51 additions & 0 deletions projects/Analog Clock/analog_clock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import tkinter as tk
from math import sin, cos, pi


def update_clock():
current_time = time_var.get()
seconds = current_time % 60
minutes = (current_time // 60) % 60
hours = (current_time // 3600) % 12

seconds_angle = 90 - seconds * 6
minutes_angle = 90 - minutes * 6 - seconds * 0.1
hours_angle = 90 - (hours * 30 + minutes * 0.5)

canvas.delete("all")

canvas.create_oval(50, 50, 250, 250)

for i in range(1, 13):
angle = 90 - i * 30
x = 150 + 85 * cos(angle * (pi / 180))
y = 150 - 85 * sin(angle * (pi / 180))
canvas.create_text(x, y, text=str(i), font=("Arial", 12, "bold"))

draw_hand(150, 150, seconds_angle, 80, 1)
draw_hand(150, 150, minutes_angle, 70, 2)
draw_hand(150, 150, hours_angle, 50, 4)

time_var.set(current_time + 1)

root.after(1000, update_clock)


def draw_hand(x, y, angle, length, width):
radian_angle = angle * (pi / 180)
end_x = x + length * cos(radian_angle)
end_y = y - length * sin(radian_angle)
canvas.create_line(x, y, end_x, end_y, width=width)


root = tk.Tk()
root.title("Analog Clock")

canvas = tk.Canvas(root, width=350, height=350)
canvas.pack()

time_var = tk.IntVar()
time_var.set(10 * 3600)

update_clock()
root.mainloop()
50 changes: 50 additions & 0 deletions projects/AnalogClock/analog_clock
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import tkinter as tk
from math import sin, cos, pi

def update_clock():
current_time = time_var.get()
seconds = current_time % 60
minutes = (current_time // 60) % 60
hours = (current_time // 3600) % 12

# Calculation of the angles for the clock hands (in degrees)
seconds_angle = 90 - seconds * 6
minutes_angle = 90 - minutes * 6 - seconds * 0.1
hours_angle = 90 - (hours * 30 + minutes * 0.5)

canvas.delete("all") #Deletes all previous drawings

canvas.create_oval(50, 50, 250, 250) #To draw clock face

for i in range(1, 13): # Drawing clock numbers
angle = 90 - i * 30 #Calculation of the angle for each number
x = 150 + 85 * cos(angle * (pi / 180))
y = 150 - 85 * sin(angle * (pi / 180))
canvas.create_text(x, y, text=str(i), font=("Arial", 12, "bold"))

draw_hand(150, 150, seconds_angle, 80, 1)
draw_hand(150, 150, minutes_angle, 70, 2)
draw_hand(150, 150, hours_angle, 50, 4)

time_var.set(current_time + 1) # Updating the time

root.after(1000, update_clock) # Updating the clock every 1000ms (1 second)

def draw_hand(x, y, angle, length, width):
radian_angle = angle * (pi / 180)
end_x = x + length * cos(radian_angle)
end_y = y - length * sin(radian_angle)
canvas.create_line(x, y, end_x, end_y, width=width)

root = tk.Tk() # Creating the main window
root.title("Analog Clock")

canvas = tk.Canvas(root, width=350, height=350)
canvas.pack()

time_var = tk.IntVar()
time_var.set(10 * 3600)

update_clock() # Starting the clock update function
root.mainloop() # Running the Tkinter main loop

29 changes: 29 additions & 0 deletions projects/Audiobook/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# PDF Text-to-Speech Reader

This Python script uses `pyttsx3` and `PyPDF2` to read the text content of a PDF file and convert it to speech using text-to-speech synthesis. It allows for playback of the PDF content and provides a hotkey ("q") to stop the playback at any time.

## Dependencies

- `pyttsx3`: A text-to-speech conversion library in Python.
- `PyPDF2`: A library to handle PDF files.
- `keyboard`: A library to listen for keyboard events.

## Usage

1. Install the required libraries using pip:

```bash
pip install pyttsx3 PyPDF2 keyboard
```

2. Run the script and provide the PDF file name when prompted:

```bash
python pdf_text_to_speech.py
```

3. Press 'q' during playback to stop the text-to-speech playback.

## How it Works

The script takes a PDF file as input, extracts the text content from each page, and uses `pyttsx3` to read it out loud. The playback can be stopped at any time by pressing the 'q' key.
4 changes: 4 additions & 0 deletions projects/Audiobook/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pyttsx3
PyPDF2
threading
keyboard
75 changes: 60 additions & 15 deletions projects/BMI_calculator/BMI calculator.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,60 @@
height = float(input("enter your height in m: "))
weight = float(input("enter your weight in kg: "))

bmi = round(weight / (height**2))

if bmi <= 18.5:
print(f"Your BMI is {bmi}, you are underweight.")
elif bmi <= 25:
print(f"Your BMI is {bmi}, you have a normal weight.")
elif bmi <= 30:
print(f"Your BMI is {bmi}, you are slightly overweight.")
elif bmi <= 35:
print(f"Your BMI is {bmi}, you are obese.")
else:
print(f"Your BMI is {bmi}, you are clinically obese.")
def calculate_bmi(height, weight):
"""
Calculate BMI given height (in meters) and weight (in kilograms).
Args:
height (float): Height in meters.
weight (float): Weight in kilograms.
Returns:
float: Calculated BMI.
"""
try:
bmi = round(weight / (height**2), 2)
return bmi
except ZeroDivisionError:
return None


def interpret_bmi(bmi):
"""
Interpret the BMI and provide a classification.
Args:
bmi (float): Calculated BMI.
Returns:
str: BMI interpretation.
"""
if bmi is None:
return "Invalid input. Height should be greater than 0."

if bmi < 18.5:
return f"Your BMI is {bmi}, you are underweight."
elif bmi < 24.9:
return f"Your BMI is {bmi}, you have a normal weight."
elif bmi < 29.9:
return f"Your BMI is {bmi}, you are overweight."
elif bmi < 34.9:
return f"Your BMI is {bmi}, you are obese (Class I)."
elif bmi < 39.9:
return f"Your BMI is {bmi}, you are obese (Class II)."
else:
return f"Your BMI is {bmi}, you are obese (Class III)."


def main():
try:
height = float(input("Enter your height in meters: "))
weight = float(input("Enter your weight in kilograms: "))

bmi = calculate_bmi(height, weight)
result = interpret_bmi(bmi)
print(result)

except ValueError:
print("Invalid input. Please enter numerical values for height and weight.")


if __name__ == "__main__":
main()
57 changes: 57 additions & 0 deletions projects/BMI_calculator/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# BMI Calculator

This Python script calculates Body Mass Index (BMI) based on a person's height and weight. It then interprets the BMI to provide a classification ranging from underweight to clinically obese.

## How to Use

1. Make sure you have Python installed on your system.

2. Clone or download the repository.

3. Open a terminal or command prompt and navigate to the project directory.

4. Run the script by executing the following command:

```bash
python bmi_calculator.py
```

5. Follow the on-screen instructions to input your height (in meters) and weight (in kilograms).

6. The program will display your BMI and the corresponding classification.

## Code Structure

- `bmi_calculator.py`: The main Python script containing the BMI calculation and interpretation logic.
- `README.md`: This file, providing an overview of the BMI calculator and usage instructions.

## Functions

### `calculate_bmi(height, weight)`

Calculate BMI given height (in meters) and weight (in kilograms).

- Parameters:
- `height` (float): Height in meters.
- `weight` (float): Weight in kilograms.

- Returns:
- float: Calculated BMI.

### `interpret_bmi(bmi)`

Interpret the BMI and provide a classification.

- Parameters:
- `bmi` (float): Calculated BMI.

- Returns:
- str: BMI interpretation.

### `main()`

The main function to execute the BMI calculation and interpretation.

## Error Handling

The script handles invalid input, ensuring that only numerical values for height and weight are accepted.
Loading

0 comments on commit 6b4342f

Please sign in to comment.