• Nov 19, 2022 •CodeCatch
0 likes • 0 views
""" Rock Paper Scissors ---------------------------------------- """ import random import os import re os.system('cls' if os.name=='nt' else 'clear') while (1 < 2): print "\n" print "Rock, Paper, Scissors - Shoot!" userChoice = raw_input("Choose your weapon [R]ock], [P]aper, or [S]cissors: ") if not re.match("[SsRrPp]", userChoice): print "Please choose a letter:" print "[R]ock, [S]cissors or [P]aper." continue // Echo the user's choice print "You chose: " + userChoice choices = ['R', 'P', 'S'] opponenetChoice = random.choice(choices) print "I chose: " + opponenetChoice if opponenetChoice == str.upper(userChoice): print "Tie! " #if opponenetChoice == str("R") and str.upper(userChoice) == "P" elif opponenetChoice == 'R' and userChoice.upper() == 'S': print "Scissors beats rock, I win! " continue elif opponenetChoice == 'S' and userChoice.upper() == 'P': print "Scissors beats paper! I win! " continue elif opponenetChoice == 'P' and userChoice.upper() == 'R': print "Paper beat rock, I win! " continue else: print "You win!"
• Aug 1, 2025 •AustinLeath
0 likes • 1 view
import re _proposal_regex = r'(?:(?:(IKE|ESP):)?[\w/]+(?:/NO_EXT_SEQ)?(?:, ?(IKE|ESP):[\w/]+(?:/NO_EXT_SEQ)?)*)?' _proposals_re = rf'(?P<proposals>{_proposal_regex}|)' pattern = rf'received proposals: {_proposals_re}' match = re.match(pattern, 'received proposals: ') print(match.group('proposals') if match else "No match") # Prints "No match"
• Aug 12, 2024 •AustinLeath
0 likes • 5 views
magnitude = lambda bits: 1_000_000_000_000_000_000 % (2 ** bits) sign = lambda bits: -1 ** (1_000_000_000_000_000_000 // (2 ** bits)) print("64 bit sum:", magnitude(64) * sign(64)) print("32 bit sum:", magnitude(32) * sign(32)) print("16 bit sum:", magnitude(16) * sign(16))
• Sep 6, 2020 •C S
0 likes • 2 views
def Fibonacci(n): if n<0: print("Incorrect input") # First Fibonacci number is 0 elif n==1: return 0 # Second Fibonacci number is 1 elif n==2: return 1 else: return Fibonacci(n-1)+Fibonacci(n-2) # Driver Program print(Fibonacci(9))
• Jul 8, 2025 •AustinLeath
from datetime import datetime epoch_time = 1753823646 # Example epoch time (March 15, 2023 00:00:00 UTC) # Convert epoch time to a UTC datetime object utc_datetime = datetime.utcfromtimestamp(epoch_time) print(f"Epoch time: {epoch_time}") print(f"UTC datetime: {utc_datetime}") # You can also format the output string formatted_utc_time = utc_datetime.strftime('%m-%d-%Y %H:%M:%S UTC') print(f"Formatted UTC datetime: {formatted_utc_time}")
# Python code to demonstrate # method to remove i'th character # Naive Method # Initializing String test_str = "CodeCatch" # Printing original string print ("The original string is : " + test_str) # Removing char at pos 3 # using loop new_str = "" for i in range(len(test_str)): if i != 2: new_str = new_str + test_str[i] # Printing string after removal print ("The string after removal of i'th character : " + new_str)