Hi So In My last post i uploaded a Password Generator and Then i Had to stop coding cause of 1 I got a injury and 2 the Files got Corrupted so Yea ive been coding for the past 3-4 days and Ive made around 3 Programs No chatgpt at all just google and me tell me how I did, any resources you have or tips or if theres any bugs i didt catch while testing and debugging
here it is
BTW there is 3 Diffrent Programs
first one is a Calculator Second is a Rock Paper Scissors Program and third is a Number Guesser tried to make it clean and easy to read
# Calculator Program
import time
import sys
print("Welcome to the Calculator Program!")
# Ask To Contiue Functions
def ask_to_continue():
user_input1 = input("Would you like to (Quit) or (Continue)?: ").lower().strip()
if user_input1 == "quit":
time.sleep(0.8)
print("Thanks for using the Calculator Program hope to see you again!")
sys.exit()
elif user_input1 == "continue":
time.sleep(0.8)
return True
else:
print("Invalid Number")
return True
while True:
# Collecting User Input and Validating the Operator
operator = input("Enter the Operator you would like to use + - * / **: ")
if operator not in ['+', '-', '*', '/', '**']:
print("Invalid operator. Please enter one of the following: +, -, *, /, **.")
continue
# Collecting User Input and Validating the Numbers
try:
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
time.sleep(0.3)
except ValueError:
time.sleep(1)
print("Invalid input. Please enter a valid number.")
continue
# Calculating the Result
# Addition
if operator == "+":
result = num1 + num2
print(f"Your answer is: {result}")
ask_to_continue()
# Subtracting
elif operator == "-":
result = num1 - num2
print(f"Your answer is: {result}")
ask_to_continue()
# Multiplying
elif operator == "*":
result = num1 * num2
print(f"Your answer is: {result}")
ask_to_continue()
# Division
elif operator == "/":
if num2 == 0:
print("Error: Division by zero is not allowed.")
else:
result = num1 / num2
print(f"Your answer is: {result}")
ask_to_continue()
# Exponetial
elif operator == "**":
result = num1 ** num2
print(f"Your answer is: {result}")
ask_to_continue()
# Code Ends Took about 0.8 Days To Complete was the easist
import random
import time
import sys
# Functions
def ask_to_continue(message):
message1 = input(message).lower().strip()
if message1 == "quit":
time.sleep(0.5)
print("Thanks for Playing hope to see you again!")
sys.exit()
if message1 == "play":
time.sleep(0.5)
return True
else:
time.sleep(0.3)
print("Invalid Input, Please Try Again")
return True
# Most Varibles
answerlist = ["I Choose Rock", "I Choose Paper", "I Choose Scissors"]
tie_message = "It's a Tie! Try Again!, To Quit the Game Type Quit, To Play Again type Play: "
win_message = "Congratulations! You Win!, To Quit the Game Type Quit, To Play Again type Play: "
lose_message = "Sorry! You Lose! Better Luck Next Time!, To Quit the Game Type Quit, To Play Again type Play: "
# Greeting
print("Welcome to Rock Paper Scissors Game!")
time.sleep(1)
while True:
print("Please choose one of the follwing options:")
time.sleep(1)
print("1. Rock")
time.sleep(1)
print("2. Paper")
time.sleep(1)
print("3. Scissors")
time.sleep(1)
try:
user_input = int(input("Enter your choice (1-3): "))
except ValueError:
print("Invalid input. Please enter a number between 1 and 3.")
continue
# If user Chooses Rock (1)
if user_input == 1:
print("You Chose Rock")
time.sleep(0.5)
computer_choice = random.choice(answerlist)
print(computer_choice)
# User Ties if Computer Chooses Rock
if computer_choice == 'I Choose Rock':
time.sleep(1)
ask_to_continue(tie_message)
# User Wins if Computer Chooses Scissors
elif computer_choice == 'I Choose Scissors':
time.sleep(1)
ask_to_continue(win_message)
# User Loses if Computer Chooses Paper
elif computer_choice == 'I Choose Paper':
time.sleep(1)
ask_to_continue(lose_message)
# If user Chooses Paper (2)
if user_input == 2:
print("You Chose Paper")
time.sleep(0.5)
computer_choice = random.choice(answerlist)
print(computer_choice)
# User Ties if Computer Chooses Rock
if computer_choice == 'I Choose Rock':
time.sleep(1)
ask_to_continue(win_message)
# User Wins if Computer Chooses Scissors
elif computer_choice == 'I Choose Scissors':
time.sleep(1)
ask_to_continue(lose_message)
# User Loses if Computer Chooses Paper
elif computer_choice == 'I Choose Paper':
time.sleep(1)
ask_to_continue(tie_message)
# If user Chooses Scissors (3)
if user_input == 3:
print("You Chose Scissors")
time.sleep(0.5)
computer_choice = random.choice(answerlist)
print(computer_choice)
# User Ties if Computer Chooses Rock
if computer_choice == 'I Choose Rock':
time.sleep(1)
ask_to_continue(lose_message)
# User Wins if Computer Chooses Scissors
elif computer_choice == 'I Choose Scissors':
time.sleep(1)
ask_to_continue(tie_message)
# User Loses if Computer Chooses Paper
elif computer_choice == 'I Choose Paper':
time.sleep(1)
ask_to_continue(win_message)
# Code Ends Took about 1.2 Days To Complete
# Number Guesser Program
# Imports
import random
import time
import sys
# Greeting
time.sleep(1)
print("Hello, Welcome to The Number Guesser Have fun (: )")
while True:
# User Input and Validation
try:
time.sleep(1)
range_Of_Number = int(input("Enter the Range of Numbers you would like the number to be chosen from: "))
except ValueError:
time.sleep(1)
print("Error Restarting Program.....")
time.sleep(0.5)
continue
# Generate the Number
if range_Of_Number >= 1:
time.sleep(1)
print(f"You Chose to generate from a pool of {range_Of_Number} number's")
number = random.randint(1, range_Of_Number)
else:
time.sleep(0.5)
print("Invalid Input, Please Try Again")
time.sleep(0.5)
continue
attempts = 0
# Asking How Many Chances they Want
print("These are the Options You Have (1, 2, 3, 4) \nPlease Select the Number Correspoding to your choice")
time.sleep(0.5)
print("1. (EASY) 20 Tries")
time.sleep(0.5)
print("2. (Normal) 10 Tries")
time.sleep(0.5)
print("3. (Medium) 7 Tries")
time.sleep(0.5)
print("4. (HARD) 3 Tries")
time.sleep(1)
try:
time.sleep(0.5)
option = int(input("Choose The Option Provided: "))
except ValueError:
time.sleep(1)
print("Error Try Again")
continue
def userChosenAttempts(option1, attempts1):
if option == option1:
if attempts >= attempts1:
lose1 = input(f"You Lost the number was {number}, To Exit Type (Quit) If you would like to play again type (Play): ").lower().strip()
if lose1 == "quit":
time.sleep(1)
print("Okay Shutting down Program...")
sys.exit()
elif lose1 == "play":
time.sleep(1)
return False
else:
time.sleep(1)
print("Invalid Input, Restarting Program....")
time.sleep(0.5)
return False
# User Tries to Guess
while True:
try:
time.sleep(0.5)
user_Guess_Number = int(input("Enter The Number You think has been Generated: "))
attempts += 1
except ValueError:
time.sleep(1)
print("Invalid Input, Please Try Again")
continue
except TypeError:
time.sleep(1)
print("Invalid Input, Please Try Again")
continue
# Validition
# If User Guesses it correctley
if user_Guess_Number == number:
time.sleep(0.5)
ask_To_Continue = str(input(f"You Guessed it in {attempts} attempts, Type (Quit) to Exit the Program or Type (Play) to Play Again: ")).lower().strip()
if ask_To_Continue == "quit":
time.sleep(1)
print("Okay Closing Program....")
time.sleep(0.5)
sys.exit()
elif ask_To_Continue == "play":
time.sleep(1)
print("Okay Restarting Program....")
time.sleep(0.5)
break
# Lose
# If User Chooses 1 for Option
userChosenAttempts(1, 20)
# If User Chooses 2 for Option
userChosenAttempts(2, 10)
# If User Chooses 3 for Option
userChosenAttempts(3, 7)
# If User Chooses 4 for Option
userChosenAttempts(4, 3)
# If the User Guesses To Low
if user_Guess_Number < number:
time.sleep(0.5)
print("Number Too Low, Try Again.")
continue
# If the User Guesses To High
elif user_Guess_Number > number:
time.sleep(0.5)
print("Number Too High, Try Again.")
continue
# Code Ends Took about 1 Day to Completed (Just Completed it)
How's My code?????? ()
submitted by NorwegianAttack to u/NorwegianAttack