Skip to content

Instantly share code, notes, and snippets.

View MPramodhkumar's full-sized avatar
🎯
Focusing

Pramodhkumar MPramodhkumar

🎯
Focusing
View GitHub Profile
@MPramodhkumar
MPramodhkumar / gist:9d3f1f86b5a6f8d79860b028509cc0c4
Created September 27, 2023 16:08
Rock-Scissors-Paper-Game.py
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 \
@MPramodhkumar
MPramodhkumar / SimpleNoteTakingApplication.py
Last active November 18, 2023 04:44
Develop a basic note-taking application where users can create, view, and edit notes. Implement functionalities like adding titles, saving notes to files, and displaying a list of saved notes. python code
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()
#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}')
@MPramodhkumar
MPramodhkumar / BinarySearchTree.py
Created May 20, 2023 18:40
In this code, the Node class represents a node in the binary search tree. Each node has a value and references to its left and right child nodes. The BST class represents the binary search tree itself and provides methods to insert a value into the tree, search for a value, and perform an inorder traversal of the tree. To use the binary search t…
class Node:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
class BST:
def __init__(self):
self.root = None
@MPramodhkumar
MPramodhkumar / StackCalculator.py
Last active November 18, 2023 05:06
In this code, the StackCalculator class represents a stack-based calculator. It has methods to push a number onto the stack, pop the top number from the stack, perform addition, subtraction, multiplication, and division operations, and display the contents of the stack. The main function serves as the entry point of the program and provides a si…
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()
@MPramodhkumar
MPramodhkumar / password Generator.py
Last active March 30, 2024 09:29
In this code, the generate_password function takes a length parameter and generates a random password of that length. It uses the string module from the Python Standard Library to define the characters that can be used in the password. It then uses the random.choice function to randomly select characters from the defined character set and concat…
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
@MPramodhkumar
MPramodhkumar / CaesarCipher1.py
Last active April 10, 2023 14:27
Caesar cipher using Manual and Mathmatical expresions in Python Programming
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=''
@MPramodhkumar
MPramodhkumar / caesercipher.py
Created March 12, 2023 15:32
Caeser Cipher in substitution technique in python
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==' ':
@MPramodhkumar
MPramodhkumar / TowersofHonoi.py
Last active February 19, 2023 02:15
TowersofHonoi problem in Python
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:"))
@MPramodhkumar
MPramodhkumar / WaterJug.py
Created December 27, 2022 05:10
Water Jug problem in AI
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)