Skip to content

Commit

Permalink
Fix code style issues with Black
Browse files Browse the repository at this point in the history
  • Loading branch information
lint-action committed Jul 23, 2023
1 parent 1d265a3 commit d8eaa81
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 81 deletions.
2 changes: 1 addition & 1 deletion projects/AES256/AES256.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from Cryptodome.Random import get_random_bytes
import platform

#For different OS
# For different OS
if platform.system() == "Windows":
os.system("cls")
else:
Expand Down
4 changes: 3 additions & 1 deletion projects/Alarm Clock/alarm_clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ def alarm():
print("Wake Up now!")
# play sound continuously
mixer.init()
mixer.music.load('sound.wav')
mixer.music.load("sound.wav")
mixer.music.play()


def stop_alarm():
mixer.music.stop()


Label(root, text="Alarm Clock", font=("Helvetica 20 bold"), fg="red").pack(pady=10)
Label(root, text="Set Time", font=("Helvetica 15 bold")).pack()

Expand Down
2 changes: 2 additions & 0 deletions projects/Blind_Auction/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
bids = {}
is_game_finished = False


# Function to compare the bids and find the highest bidder
def compare(bidding_record):
highest_bidder = 0
Expand All @@ -23,6 +24,7 @@ def compare(bidding_record):
winner = bidder
print(f"The winner is {winner} with the highest bid of {highest_bidder}.")


# Main loop for the bidding process
while not is_game_finished:
name = input("Enter your name: ")
Expand Down
163 changes: 97 additions & 66 deletions projects/TicTacToe-TylerPear/main.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
spot = ' '
leftSpot = f'{spot} |'
middleSpot = f' {spot} | '
rightSpot = f'{spot}'
board = [[leftSpot, middleSpot, rightSpot],
['___', '____', '__'],
[leftSpot, middleSpot, rightSpot],
['___', '____', '__'],
[leftSpot, middleSpot, rightSpot]]
spot = " "
leftSpot = f"{spot} |"
middleSpot = f" {spot} | "
rightSpot = f"{spot}"
board = [
[leftSpot, middleSpot, rightSpot],
["___", "____", "__"],
[leftSpot, middleSpot, rightSpot],
["___", "____", "__"],
[leftSpot, middleSpot, rightSpot],
]

i = 0
player = ''
player = ""


def print_board():
print(board[0][0], end="")
print(board[0][1], end="")
Expand All @@ -27,123 +31,150 @@ def print_board():
print(board[4][1], end="")
print(board[4][2], end="\n\n")


def collect_input(player):
print('KEY: TL = Top Left, TM = Top Middle, TR = Top Right')
print(' ML = Middle Left, MM = Middle Middle, MR = Middle Right')
print(' BL = Bottom Left, BM = Bottom Middle, BR = Bottom Right')
move = input(f'Player {player}, Type Your Move: ')
print("KEY: TL = Top Left, TM = Top Middle, TR = Top Right")
print(" ML = Middle Left, MM = Middle Middle, MR = Middle Right")
print(" BL = Bottom Left, BM = Bottom Middle, BR = Bottom Right")
move = input(f"Player {player}, Type Your Move: ")
valid = False
if move in ['TL', 'TM', 'TR', 'ML', 'MM', 'MR', 'BL', 'BM', 'BR']:
if move in ["TL", "TM", "TR", "ML", "MM", "MR", "BL", "BM", "BR"]:
valid = True
return move
else:
while valid == False:
move = input('Type a valid move:')
if move in ['TL', 'TM', 'TR', 'ML', 'MM', 'MR', 'BL', 'BM', 'BR']:
move = input("Type a valid move:")
if move in ["TL", "TM", "TR", "ML", "MM", "MR", "BL", "BM", "BR"]:
valid = True
return move


def examine_move(board, x, y, msg):
taken = False

if 'X' in board[x][y] or 'O' in board[x][y]:
if "X" in board[x][y] or "O" in board[x][y]:
taken = True
else:
board[x][y] = msg

return taken

def change_board(move, board, player):

def change_board(move, board, player):
taken = False

#TOP ROW
# TOP ROW

if move == 'TL':
taken = examine_move(board, 0, 0, f' {player}|')
elif move == 'TM':
taken = examine_move(board, 0, 1, f' {player} | ')
elif move == 'TR':
taken = examine_move(board, 0, 2, f'{player}')
if move == "TL":
taken = examine_move(board, 0, 0, f" {player}|")
elif move == "TM":
taken = examine_move(board, 0, 1, f" {player} | ")
elif move == "TR":
taken = examine_move(board, 0, 2, f"{player}")

#MIDDLE ROW
# MIDDLE ROW

if move == 'ML':
taken = examine_move(board, 2, 0, f' {player}|')
elif move == 'MM':
taken = examine_move(board, 2, 1, f' {player} | ')
elif move == 'MR':
taken = examine_move(board, 2, 2, f'{player}')
if move == "ML":
taken = examine_move(board, 2, 0, f" {player}|")
elif move == "MM":
taken = examine_move(board, 2, 1, f" {player} | ")
elif move == "MR":
taken = examine_move(board, 2, 2, f"{player}")

#BOTTOM ROW
# BOTTOM ROW

if move == 'BL':
taken = examine_move(board, 4, 0, f' {player}|')
elif move == 'BM':
taken = examine_move(board, 4, 1, f' {player} | ')
elif move == 'BR':
taken = examine_move(board, 4, 2, f'{player}')
if move == "BL":
taken = examine_move(board, 4, 0, f" {player}|")
elif move == "BM":
taken = examine_move(board, 4, 1, f" {player} | ")
elif move == "BR":
taken = examine_move(board, 4, 2, f"{player}")

if taken:
move = input('That spot is taken! Pick another spot: ')
move = input("That spot is taken! Pick another spot: ")
change_board(move, board, player)

return board


def change_player(i):
if i % 2 == 0: return 'O'
else: return 'X'
if i % 2 == 0:
return "O"
else:
return "X"

def check_for_win(board, player):

#Check Lists
if board[0] == [f' {player}|', f' {player} | ', f'{player}']:
def check_for_win(board, player):
# Check Lists
if board[0] == [f" {player}|", f" {player} | ", f"{player}"]:
return True
elif board[2] == [f' {player}|', f' {player} | ', f'{player}']:
elif board[2] == [f" {player}|", f" {player} | ", f"{player}"]:
return True
elif board[4] == [f' {player}|', f' {player} | ', f'{player}']:
elif board[4] == [f" {player}|", f" {player} | ", f"{player}"]:
return True

#Check Columns
elif board[0][0] == f' {player}|' and board[2][0] == f' {player}|' and board[4][0] == f' {player}|':
# Check Columns
elif (
board[0][0] == f" {player}|"
and board[2][0] == f" {player}|"
and board[4][0] == f" {player}|"
):
return True
elif board[0][1] == f' {player} | ' and board[2][1] == f' {player} | ' and board[4][1] == f' {player} | ':
elif (
board[0][1] == f" {player} | "
and board[2][1] == f" {player} | "
and board[4][1] == f" {player} | "
):
return True
elif board[0][2] == f'{player}' and board[2][2] == f'{player}' and board[4][2] == f'{player}':
elif (
board[0][2] == f"{player}"
and board[2][2] == f"{player}"
and board[4][2] == f"{player}"
):
return True

#Check Diagonal
elif board[0][0] == f' {player}|' and board[2][1] == f' {player} | ' and board[4][2] == f'{player}':
# Check Diagonal
elif (
board[0][0] == f" {player}|"
and board[2][1] == f" {player} | "
and board[4][2] == f"{player}"
):
return True
elif board[0][2] == f'{player}' and board[2][1] == f' {player} | ' and board[4][0] == f' {player}|':
elif (
board[0][2] == f"{player}"
and board[2][1] == f" {player} | "
and board[4][0] == f" {player}|"
):
return True

else: return False
else:
return False


def player_won(board):
xwon = check_for_win(board, 'X')
owon = check_for_win(board, 'O')
xwon = check_for_win(board, "X")
owon = check_for_win(board, "O")

if xwon or owon:
return True
else: return False
else:
return False


if __name__ == '__main__':
if __name__ == "__main__":
catsgame = False
while player_won(board) == False and catsgame == False:
i += 1
if i == 10:
print('Cat\'s Game!')
print("Cat's Game!")
catsgame = True
else:
player = change_player(i)
board = change_board(collect_input(player), board, player)
print_board()

if catsgame == False:
if player == 'X':
print('Congrats! X Wins!')
elif player == 'O':
print('Congrats! O Wins!')

if player == "X":
print("Congrats! X Wins!")
elif player == "O":
print("Congrats! O Wins!")
25 changes: 15 additions & 10 deletions projects/ToDoList/to_do_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,65 @@ def add_task(task):
todo_list.append(task)
print("Task added!")


def remove_task(task_num):
if 0 <= task_num < len(todo_list):
del todo_list[task_num]
print("Task removed!")
else:
print("Invalid task number!")


def display_tasks():
if not todo_list: # If list is empty
if not todo_list: # If list is empty
print("No tasks to display.")
else:
for index, task in enumerate(todo_list, start=1):
print(f"{index}. {task}")


def get_choice():
while True:
try:
choice = int(input("Type a number: 1. Adding a task, 2. Removing a task, 3. Displaying tasks, 4. Quit: "))
choice = int(
input(
"Type a number: 1. Adding a task, 2. Removing a task, 3. Displaying tasks, 4. Quit: "
)
)
if 1 <= choice <= 4:
return choice
else:
print("Invalid choice. Try again.")
except ValueError:
print("Please enter a number between 1 and 4.")

if __name__ == "__main__":

if __name__ == "__main__":
todo_list = []

print("Welcome to ToDo List!")

while True:
user_choice = get_choice()

#Adding a task
# Adding a task
if user_choice == 1:
new_task = input("Type a new task: ")
add_task(new_task)

#Removing a task
# Removing a task
elif user_choice == 2:
if not todo_list: # If list is empty
if not todo_list: # If list is empty
print("No tasks to remove.")
else:
task_num = int(input("Enter the task number to delete: ")) - 1
remove_task(task_num)

#Displaying tasks
# Displaying tasks
elif user_choice == 3:
display_tasks()

#Quit
# Quit
elif user_choice == 4:
print("Goodbye!")
break
Expand All @@ -64,5 +71,3 @@ def get_choice():
# CODE CONTRIBUTED BY: Ota Hina

#####################################


10 changes: 7 additions & 3 deletions projects/WebButtonSimpelGUI/WebButtonSimpelGUI.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
#Dont forget to import icon path
# Dont forget to import icon path
import webbrowser as wb
import tkinter as tk
from PIL import Image, ImageTk


def button1_click():
print("Button 1 clicked!")
wb.open("https://www.google.com/")


def button2_click():
print("Button 2 clicked!")
wb.open("https://www.youtube.com/")


def button3_click():
print("Button 3 clicked!")
wb.open("https://github.com/")


# Create the main window
window = tk.Tk()

Expand All @@ -33,5 +39,3 @@ def button3_click():

# Start the main event loop
window.mainloop()


0 comments on commit d8eaa81

Please sign in to comment.