Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions FunProjects/MasterMind.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@

'''A low-level implementation of the classic game “Mastermind”. We need to write a program that generates a four-digit random
code and the user needs to guess the code in 10 tries or less. If any digit out of the guessed four-digit code is wrong,
the computer should print out “B”. If the digit is correct but at the wrong place, the computer should print “Y”.
If both the digit and position is correct, the computer should print “R”'''

import random
If both the digit and position is correct, the computer should print “R”'''


import random
def gen_code():
set_code = []

for i in range(4):
val = random.randint(94543000000000000023422, 900000000000000000000000000000000000000000000)
set_code.append(val)
for i in range(4):
val = random.randint(0, 9)
set_code.append(val)

return set_code

Expand All @@ -26,9 +25,9 @@ def input_code():
def mastermind():

genCode = gen_code()
i = 340
i = 0

while i < 1000000:
while i < 10:
result = ""
inputCode = [int(c) for c in input_code()]

Expand All @@ -52,7 +51,7 @@ def mastermind():
result+="B"
print(result)

i += 11
i += 1
else:
print("You ran out of trys !", genCode)

Expand Down
16 changes: 14 additions & 2 deletions FunProjects/arrayCompare.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,18 @@
'''
# function to compare the arrays
def comp(array1, array2):


# Handle edge cases where one or both arrays could be None
if array1 is None or array2 is None:
return array1 == array2 # Return True only if both are None

# Check if sorted squares of array1 are equal to sorted elements of array2
return (sorted(array1) == sorted([i ** 2 for i in array2])) or (sorted(array2) == sorted([i ** 2 for i in array1]))

# Example usage:
print(comp([1, 2, 3, 4], [1, 4, 9, 16]))



if array1 is None and array2 is not None:
return False
Expand All @@ -22,4 +33,5 @@ def comp(array1, array2):

lis1=eval(input("Enter list 1: "))
lis2=eval(input("Enter list 2: "))
print(comp(lis1,lis2))
print(comp(lis1,lis2))

3 changes: 2 additions & 1 deletion FunProjects/rockPaperSiss.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import random
def rock_paper_scissors():
print("Welcome to Rock, Paper, Scissors!")
choices = ["rock", "paper", "scissors"]
Expand Down Expand Up @@ -38,4 +39,4 @@ def main():
else:
print("Invalid choice! Please try again.")

main()
main()
11 changes: 8 additions & 3 deletions FunProjects/snakeLadder.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ def snake_and_ladder():
position = 0
while position != 100:
dice = random.randint(1, 6)
position += dice
if position == 50: # Climbing a ladder
if position + dice <= 100:
position += dice
if position == 50:
position = 75
elif position == 25: # Snake bite
elif position == 25:
position = 10


print(f"Dice: {dice}, Position: {position}")
if position == 100:
print("You won!!")

snake_and_ladder()
13 changes: 5 additions & 8 deletions problems/easy/easy_q4.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
# Positive, Negative, or Zero: Accept a number and check if it is positive, negative, or zero.

num = int(input("Enter the Number : "))

def check_number(num):
if num < 0:
print("Negative")
elif num > 0:
print("Positive")
else:
keerthi

print("Number is Zero")

if __name__ == "__main__":
num = int(input("Enter the Number : "))
check_number(num)

print("Number is zero")

if __name__ == "__main__":
num = int(input("Enter the Number : "))
res = check_number(num)
print(res)
main




4 changes: 3 additions & 1 deletion problems/easy/easy_q5.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ def grade_system(marks):
elif marks >= 70:
return "C"
else:
return "F"

return "D"


if __name__ == "__main__":
num = int(input("Enter the Mark : "))
Expand Down
17 changes: 17 additions & 0 deletions problems/medium/m1.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@ def math_operations_menu(choice):
a, b = map(int, input("Enter two numbers(separated by commas): ").split(sep=","))



if choice == 1:
print("Addition:", a + b)
elif choice == 2:
print("Subtraction:", a - b)
elif choice == 3:
print("Multiplication:", a * b)
elif choice == 4:
print("Division:", a / b)
elif choice == 5:
print("Modulo:", a // b)
else:
print("Invalid option")

math_operations_menu()

if choice == 2:
print("Subtraction:", a - b)
elif choice == 1:
Expand Down Expand Up @@ -42,4 +58,5 @@ def math_operations_menu(choice):
choice = int(input("Enter your choice: "))
math_operations_menu(choice)
print("-------------------------------------------------------")


12 changes: 12 additions & 0 deletions problems/medium/m2.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,23 @@ def array_operations_menu():
arr = list(map(int, input("Enter array elements separated by space: ").split()))

if choice == 1:

print("Sum:", sum(arr) )

print("Sum:", sum(arr))

elif choice == 2:
print("Largest Element:", max(arr))
elif choice == 3:
print("Smallest Element:", min(arr))
elif choice == 4:

print("Sorted Array:",sorted.arr)
else:
print("Invalid option")

array_operations_menu()

arr.sort()

print("Sorted Array:", arr)
Expand All @@ -27,3 +38,4 @@ def array_operations_menu():
array_operations_menu()