Skip to content
Merged
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
66 changes: 66 additions & 0 deletions Pomodoro Timer/App
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import sys
import time
from PyQt6.QtCore import QTimer, Qt
from PyQt6.QtWidgets import QApplication, QWidget, QVBoxLayout, QPushButton, QLabel
from PyQt6.QtGui import QFont
from colorama import init, Fore, Style

# Initialize colorama
init(autoreset=True)

class CountdownApp(QWidget):
def __init__(self):
super().__init__()

self.initUI()

def initUI(self):
self.layout = QVBoxLayout()

self.label = QLabel("00:00")
self.label.setFont(QFont('Arial', 48))
self.label.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.layout.addWidget(self.label)

self.work_button = QPushButton('Start Work Session')
self.work_button.clicked.connect(lambda: self.start_countdown(25, "Work Session"))
self.layout.addWidget(self.work_button)

self.break_button = QPushButton('Start Break')
self.break_button.clicked.connect(lambda: self.start_countdown(5, "Break"))
self.layout.addWidget(self.break_button)

self.setLayout(self.layout)

self.setWindowTitle('Countdown Timer')
self.setGeometry(300, 300, 300, 200)
self.show()

def start_countdown(self, minutes, session_name):
self.work_button.setDisabled(True)
self.break_button.setDisabled(True)
self.seconds = minutes * 60
self.session_name = session_name
self.update_timer()
self.timer = QTimer(self)
self.timer.timeout.connect(self.update_timer)
self.timer.start(1000)

def update_timer(self):
mins, secs = divmod(self.seconds, 60)
timer_text = f'{mins:02d}:{secs:02d}'
self.label.setText(timer_text)

if self.seconds == 0:
self.timer.stop()
self.label.setText(f'{self.session_name} is over!')

self.work_button.setDisabled(False)
self.break_button.setDisabled(False)
else:
self.seconds -= 1

if __name__ == '__main__':
app = QApplication(sys.argv)
ex = CountdownApp()
sys.exit(app.exec())
30 changes: 30 additions & 0 deletions Pomodoro Timer/pomodoro.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import time
from tqdm import tqdm
from colorama import init, Fore, Style

# Initialize colorama
init(autoreset=True)

def countdown(minutes, name):
print(name)
seconds = minutes * 60
bar_format = Fore.GREEN + '{l_bar}{bar}| {remaining} seconds' + Style.RESET_ALL
with tqdm(total=seconds, desc='Time remaining', bar_format=bar_format, ncols=100) as pbar:
while seconds:
mins, secs = divmod(seconds, 60)
timer = f'{mins:02d}:{secs:02d}'
print(Fore.YELLOW + timer, end='\r' + Style.RESET_ALL)
time.sleep(1)
seconds -= 1
pbar.update(1)
print(Fore.RED + '\nTime is up!' + Style.RESET_ALL)

# Example usage:
countdown(1,"Work Session") # for a 1-minute work session
countdown(1,"Break") # for a 1-minute break

# Example use, running for infinity:

while True:
countdown(25,"Work Session")
countdown(5, "Break")
1 change: 1 addition & 0 deletions Python-Scripts
Submodule Python-Scripts added at 3ad829
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ More information on contributing and the general code of conduct for discussion
| QR Code Generator | [QR Code Generator](https://github.com/DhanushNehru/Python-Scripts/tree/master/QR%20Code%20Generator) | This is generate a QR code from the provided link |
| Random Color Generator | [Random Color Generator](https://github.com/DhanushNehru/Python-Scripts/tree/master/Random%20Color%20Generator) | A random color generator that will show you the color and values! |
| Remove Background | [Remove Background](https://github.com/DhanushNehru/Python-Scripts/tree/master/Remove%20Background) | Removes the background of images. |
| ROCK-PAPER-SCISSOR | [ROCK-PAPER-SCISSOR](https://github.com/DhanushNehru/Python-Scripts/tree/master/Rock%20Paper%20Scissor) | A game of Rock Paper Scissors. |
| ROCK-PAPER-SCISSOR | [ROCK-PAPER-SCISSOR](https://github.com/DhanushNehru/Python-Scripts/tree/master/Rock%20Paper%20Scissor) | A game of Rock Paper Scissors.
| Rock Paper Scissors -New | [Rock Paper Scissors -New](https://github.com/bbob122/Python-Scripts/tree/new_features/Rock%20Paper%20Scissors%20-New) | Updated Rock Paper Scissors with new feature. |
| Run Then Notify | [Run Then Notify](https://github.com/DhanushNehru/Python-Scripts/tree/master/Run%20Then%20Notify) | Runs a slow command and emails you when it completes execution. |
| Selfie with Python | [Selfie_with_Python](https://github.com/DhanushNehru/Python-Scripts/tree/master/Selfie%20with%20Python) | Take your selfie with python . |
| Simple TCP Chat Server | [Simple TCP Chat Server](https://github.com/DhanushNehru/Python-Scripts/tree/master/TCP%20Chat%20Server) | Creates a local server on your LAN for receiving and sending messages! |
Expand Down
88 changes: 44 additions & 44 deletions Rock Paper Scissor/rps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,81 +2,81 @@

# Print multiline instruction
# performstring concatenation of string
print("Winning Rules of the Rock paper scissor game as follows: \n"
+"Rock vs paper->paper wins \n"
+ "Rock vs scissor->Rock wins \n"
+"paper vs scissor->scissor wins \n")
print("Winning Rules of the Rock Paper Scissor game as follows: \n"
+"Rock vs Paper->Paper wins \n"
+ "Rock vs Scissor->Rock wins \n"
+"Paper vs Scissor->Scissor wins \n"
+"Similar selcetions result in a draw. \n")

while True:
print("Enter choice by entering the appropiate number \n 1. Rock \n 2. paper \n 3. scissor \n")
print("Enter choice by entering the appropiate number \n 1. Rock \n 2. Paper \n 3. Scissor \n")

# take the input from user
choice = int(input("User turn: "))
choice = int(input("It is your turn, please choose: "))

# OR is the short-circuit operator
# if any one of the condition is true
# then it return True value

# looping until user enter invalid input
while choice > 3 or choice < 1:
choice = int(input("enter valid input: "))
choice = int(input("Please enter a number between 1 and 3: "))


# initialize value of choice_name variable
# corresponding to the choice value
if choice == 1:
choice_name = 'Rock'
elif choice == 2:
choice_name = 'paper'
choice_name = 'Paper'
else:
choice_name = 'scissor'
choice_name = 'Scissor'

# print user choice
print("user choice is: " + choice_name)
print("\nNow its computer turn.......")
print("You chosed: " + choice_name)
print("\nNow its my turn.......")

# Computer chooses randomly any number
# among 1 , 2 and 3. Using randint method
# of random module
comp_choice = random.randint(1, 3)

# looping until comp_choice value
# is equal to the choice value
while comp_choice == choice:
comp_choice = random.randint(1, 3)

# initialize value of comp_choice_name
# variable corresponding to the choice value
if comp_choice == 1:
comp_choice_name = 'Rock'
elif comp_choice == 2:
comp_choice_name = 'paper'
else:
comp_choice_name = 'scissor'
#check for draw
if comp_choice == choice:
print("We both choose "+choice_name)
print(" - It´s a draw")
else:
# initialize value of comp_choice_name
# variable corresponding to the choice value
if comp_choice == 1:
comp_choice_name = 'Rock'
elif comp_choice == 2:
comp_choice_name = 'Paper'
else:
comp_choice_name = 'Scissor'

print("Computer choice is: " + comp_choice_name)
print("I did choose: " + comp_choice_name)

print(choice_name + " V/s " + comp_choice_name)
print(choice_name + " V/s " + comp_choice_name)

# condition for winning
if((choice == 1 and comp_choice == 2) or
(choice == 2 and comp_choice ==1 )):
print("paper wins => ", end = "")
result = "paper"
# condition for winning
if((choice == 1 and comp_choice == 2) or
(choice == 2 and comp_choice ==1 )):
print("Paper wins => ", end = "")
result = "Paper"

elif((choice == 1 and comp_choice == 3) or
(choice == 3 and comp_choice == 1)):
print("Rock wins =>", end = "")
result = "Rock"
else:
print("scissor wins =>", end = "")
result = "scissor"
elif((choice == 1 and comp_choice == 3) or
(choice == 3 and comp_choice == 1)):
print("Rock wins =>", end = "")
result = "Rock"
else:
print("Scissor wins =>", end = "")
result = "Scissor"

# Printing either user or computer wins
if result == choice_name:
print("<== User wins ==>")
else:
print("<== Computer wins ==>")
# Printing either user or computer wins
if result == choice_name:
print("<== User wins ==>")
else:
print("<== Computer wins ==>")

print("Do you want to play again? (Y/N)")
ans = input()
Expand Down
50 changes: 50 additions & 0 deletions Rock Paper Scissors - New Version
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import random

def get_user_choice():
choices = ["rock", "paper", "scissors", "lizard", "spock"]
user_choice = input("Enter your choice (rock, paper, scissors, lizard, spock): ").lower()
while user_choice not in choices:
user_choice = input("Invalid choice. Please enter rock, paper, scissors, lizard, or spock: ").lower()
return user_choice

def get_computer_choice():
choices = ["rock", "paper", "scissors", "lizard", "spock"]
return random.choice(choices)

def determine_winner(user_choice, computer_choice):
win_conditions = {
"scissors": ["paper", "lizard"],
"paper": ["rock", "spock"],
"rock": ["lizard", "scissors"],
"lizard": ["spock", "paper"],
"spock": ["scissors", "rock"]
}

if user_choice == computer_choice:
return "tie"
elif computer_choice in win_conditions[user_choice]:
return "user"
else:
return "computer"

def play_game():
print("Welcome to Rock, Paper, Scissors, Lizard, Spock!")

user_choice = get_user_choice()
computer_choice = get_computer_choice()

print(f"You chose: {user_choice}")
print(f"Computer chose: {computer_choice}")

winner = determine_winner(user_choice, computer_choice)

if winner == "tie":
print("It's a tie! Let's play again.")
play_game()
elif winner == "user":
print("You win!")
else:
print("Computer wins!")

if __name__ == "__main__":
play_game()
30 changes: 30 additions & 0 deletions Rock Paper Scissors -New/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Rock, Paper, Scissors, Lizard, Spock Game

This is a Python implementation of the classic Rock, Paper, Scissors game extended with two additional options: Lizard and Spock.

## Rules

- **Scissors** cuts **Paper**
- **Paper** covers **Rock**
- **Rock** crushes **Lizard**
- **Lizard** poisons **Spock**
- **Spock** smashes **Scissors**
- **Scissors** decapitates **Lizard**
- **Lizard** eats **Paper**
- **Paper** disproves **Spock**
- **Spock** vaporizes **Rock**
- **Rock** crushes **Scissors**

## How to Play

1. **Setup:** Run the Python script `rps.py`.
2. **Gameplay:**
- Enter the number of rounds you want to play.
- For each round, enter your choice: rock, paper, scissors, lizard, or spock.
- The computer will randomly select its choice.
- The winner of each round is determined based on the rules above.
- Scores (user wins, computer wins, and ties) are displayed after each round.
3. **End of Game:**
- After completing all rounds, final scores are displayed.
- You have the option to play again or exit.

Loading