This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| def get_computer_choice(): | |
| return random.choice(["Rock", "Paper", "Scissors"]) | |
| def determine_winner(player_choice, computer_choice): | |
| if player_choice == computer_choice: | |
| return "It's a tie!" | |
| elif (player_choice == "Rock" and computer_choice == "Scissors") or \ | |
| (player_choice == "Paper" and computer_choice == "Rock") or \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| notes_directory = "notes" # Directory to store notes | |
| def create_directory(): | |
| if not os.path.exists(notes_directory): | |
| os.makedirs(notes_directory) | |
| def add_note(): | |
| create_directory() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #guessing game using python | |
| import random | |
| import math | |
| l=int(input("Enter lower boundary:")) | |
| h=int(input("Enter upper boundary:")) | |
| num = random.randint(l, h) | |
| x=h-l+1 | |
| a=int(math.log(x,2)) | |
| while True: | |
| print(f'Guess a number between {l} and {h}') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Node: | |
| def __init__(self, value): | |
| self.value = value | |
| self.left = None | |
| self.right = None | |
| class BST: | |
| def __init__(self): | |
| self.root = None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class StackCalculator: | |
| def __init__(self): | |
| self.stack = [] | |
| def push(self, num): | |
| self.stack.append(num) | |
| def pop(self): | |
| if not self.is_empty(): | |
| return self.stack.pop() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| import string | |
| def generate_password(length, include_uppercase=True, include_lowercase=True, include_digits=True, include_punctuation=True, user_preference=''): | |
| # Define the characters to be used in the password based on user preferences | |
| characters = '' | |
| if include_uppercase: | |
| characters += string.ascii_uppercase | |
| if include_lowercase: | |
| characters += string.ascii_lowercase |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| while True: | |
| def fun(): | |
| print("\n1.Manual\n2.Mathamatical\n3.Exit\n") | |
| mode=input("Choose choice:") | |
| print("\n") | |
| if mode == '1': | |
| letters='abcdefghijklmnopqrstuvwxyz' | |
| num_letters=len(letters) | |
| def encrypt_decrypt(text, mode, key): | |
| result='' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| letters='abcdefghijklmnopqrstuvwxyz' | |
| num_letters=len(letters) | |
| def encrypt_decrypt(text, mode, key): | |
| result='' | |
| if mode=='d': | |
| key=-key | |
| for letter in text: | |
| letter=letter.lower() | |
| if not letter==' ': |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def TowersofHonoi(n,source,destination,intermediate): | |
| if n == 1: | |
| print("Move disk from rod {} to rod {}".format(source,destination)) | |
| elif n == 0: | |
| return | |
| else: | |
| TowersofHonoi(n-1,source,intermediate,destination) | |
| print("Move disk from rod {} to rod {}".format(source,destination)) | |
| TowersofHonoi(n-1,intermediate,destination,source) | |
| n=int(input("Enter the no.of Disks:")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def pour_water(juga,jugb): | |
| print("%d\t%d" % (juga,jugb)) | |
| if jugb == fill: | |
| return | |
| elif jugb == max2: | |
| pour_water(0,juga) | |
| elif juga != 0 and jugb == 0: | |
| pour_water(0,juga) | |
| elif juga == fill: | |
| pour_water(juga,0) |
NewerOlder