Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Commit 17ca816

Browse files
committed
Fix code style issues with Black
1 parent eae86ca commit 17ca816

5 files changed

Lines changed: 34 additions & 26 deletions

File tree

projects/Guess Number/guess_number.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ def guess(num, user_guess):
3535
print(f"\nNumber is higher than {user_guess}")
3636
lower_limit = user_guess
3737
user_guess = enter_and_verification(lower_limit + 1, upper_limit)
38-
num_of_guesses=num_of_guesses+1
38+
num_of_guesses = num_of_guesses + 1
3939
elif num < user_guess:
4040
print(f"\nNumber is lower than {user_guess}")
4141
upper_limit = user_guess
4242
user_guess = enter_and_verification(lower_limit, upper_limit - 1)
43-
num_of_guesses=num_of_guesses+1
43+
num_of_guesses = num_of_guesses + 1
4444
else:
4545
print()
4646
print(f"\nCongrats! You've guessed the correct number! It was {num}.\n")
@@ -51,7 +51,7 @@ def guess(num, user_guess):
5151
while True:
5252
play_y_n = input("Welcome to Number Guesser. If you'd like to play, press 'Y': ")
5353
if play_y_n.lower() == "y":
54-
num_of_guesses=0
54+
num_of_guesses = 0
5555
num = random.randint(smaller_number, larger_number)
5656
user_guess = enter_and_verification(lower_limit, upper_limit)
5757
guess(num, user_guess, num_of_guesses)

projects/Instagram Post Creation/main.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
from PIL import Image, ImageDraw, ImageFont
44

5+
56
def create_instagram_post(template, text, output_path):
67
# Load the template image
7-
template_path = os.path.join(os.path.dirname(__file__), "templates", "basic_template.jpg")
8+
template_path = os.path.join(
9+
os.path.dirname(__file__), "templates", "basic_template.jpg"
10+
)
811
img = Image.open(template_path)
912

1013
# Initialize the drawing context
@@ -34,4 +37,4 @@ def create_instagram_post(template, text, output_path):
3437
post_text = "My Instagram Post"
3538
output_file = "output/post.jpg"
3639

37-
create_instagram_post(template_name, post_text, output_file)
40+
create_instagram_post(template_name, post_text, output_file)

projects/Message-Spam/mesaage_spam.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
time.sleep(10)
1515

1616
# List of messages to send
17-
messages = ('Hello', 'Hey', 'Good Morning')
17+
messages = ("Hello", "Hey", "Good Morning")
1818

1919
# Send 10 random messages
2020
for _ in range(10):
2121
# Choose a random message from the list
2222
message = random.choice(messages)
23-
23+
2424
# Type and send the message using PyAutoGUI
2525
pg.write(message)
26-
pg.press('enter')
27-
26+
pg.press("enter")
27+
2828
# Pause for a random duration between 1 to 3 seconds
2929
time.sleep(random.uniform(1, 3))
Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,38 @@
11
import yt_dlp
22

3+
34
def download_youtube_video(video_url):
45
"""Downloads a YouTube video using yt-dlp."""
56

67
ydl_opts = {
7-
'outtmpl': '%(title)s.%(ext)s', # Output filename template
8+
"outtmpl": "%(title)s.%(ext)s", # Output filename template
89
}
910
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
1011
info_dict = ydl.extract_info(video_url, download=False)
11-
formats = info_dict.get('formats', None)
12-
12+
formats = info_dict.get("formats", None)
13+
1314
# Print all the available formats and ask the user to select
1415
for f in formats:
1516
print(f"{f['format_id']}:\t{f['ext']} ({f.get('format_note', None)}p)")
16-
17-
resolution_choice = input("Do you want to select from the available options? (y/n): ")
18-
19-
if resolution_choice.lower() == 'y':
17+
18+
resolution_choice = input(
19+
"Do you want to select from the available options? (y/n): "
20+
)
21+
22+
if resolution_choice.lower() == "y":
2023
format_id = input("Enter the format id of the video: ")
21-
ydl_opts['format'] = format_id
24+
ydl_opts["format"] = format_id
2225
else:
2326
# Select the highest resolution format
24-
highest_resolution = max(formats, key=lambda x: x.get('height', 0))
25-
format_id = highest_resolution['format_id']
26-
ydl_opts['format'] = format_id
27-
27+
highest_resolution = max(formats, key=lambda x: x.get("height", 0))
28+
format_id = highest_resolution["format_id"]
29+
ydl_opts["format"] = format_id
30+
2831
# Download the video
2932
ydl.download([video_url])
3033
print("Download complete using yt-dlp!")
3134

35+
3236
if __name__ == "__main__":
3337
video_url = input("Enter the URL: ")
3438
download_youtube_video(video_url)

projects/xls_to_xlsx/xls_to_xlsx.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def convert_xls_to_xlsx(file_path: str, file_format: int = 51):
1313
"""
1414
excel_app = Dispatch("Excel.Application")
1515
excel_app.Visible = False
16-
output_path = str(file_path) + 'x'
16+
output_path = str(file_path) + "x"
1717
workbook = excel_app.Workbooks.Open(file_path)
1818
workbook.SaveAs(output_path, FileFormat=file_format)
1919
workbook.Close()
@@ -36,15 +36,16 @@ def main():
3636
file_name = os.path.basename(file_path)
3737
print(f"Successfully converts {file_name}")
3838

39-
is_delete = str(input(
40-
f"Do you want to delete the old {file_name} file (y/n)? ")).lower()
39+
is_delete = str(
40+
input(f"Do you want to delete the old {file_name} file (y/n)? ")
41+
).lower()
4142

42-
if is_delete == 'y':
43+
if is_delete == "y":
4344
remove_old_file(file_path=file_path)
4445
print(f"Successfully removes {file_name}")
4546
else:
4647
pass
4748

4849

49-
if __name__ == '__main__':
50+
if __name__ == "__main__":
5051
main()

0 commit comments

Comments
 (0)