Skip to content

Instantly share code, notes, and snippets.

View MPramodhkumar's full-sized avatar
🎯
Focusing

Pramodhkumar MPramodhkumar

🎯
Focusing
View GitHub Profile
QUESTION
A robot moves in a plane starting from the original point (0,0). The robot can move UP, DOWN, LEFT, and RIGHT with given steps. Please write a program to compute the distance from the current position after a sequence of movements and the original point. If the distance is a float, then just print the nearest integer.
Input Format:
The first line of input consists of one string and one integer
The second line of input consists of one string and one integer
Same for the other new lines until the user enters a "STOP".
Output Format:
@MPramodhkumar
MPramodhkumar / GuessNumber.py
Created October 12, 2022 13:22
Python Program for Guess the random number in given attempts
#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 / TicTacToeGame.py
Created November 2, 2022 09:08
TicTacToe Game using Python...
instructions="""
This is our TicTacToe Board
1 | 2 | 3
---|---|---
4 | 5 | 6
---|---|---
7 | 8 | 9
*Instructions:
1.Insert the number(1-9)
2.You Must fill all 9 spots to get the result
@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)
@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 / 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 / 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 / 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 / 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 / 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