Skip to content
Open
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
42 changes: 42 additions & 0 deletions python/dragon_game.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#import modules
import random
import time

#create varibles
try_again = ""
cave_list = ["1","2","3","4"]
#process and display
def display_intro():
print("""You are in the Kingdom of Dragons. In front of you,
you see four caves. In cave 1, the dragon is friendly
and will share his treasure with you. The dragon in cave 2
is hungry and will eat you on sight.
The dragon in cave 3 is friendly but doesn't have any treasure. And dragon in cave 4 is hungry and he got no treasure.""")

def choose_cave():
cave = ""
while cave not in cave_list:
cave = input("Which cave will you go into(1/2/3/4) : ")
return cave

def check_cave(choosen_cave):
caves = ["Gobbles you down!","Smiles, but no treasure","Gobbles you since he even doesn't even have any treasure"]
print("You approach the cave...")
time.sleep(2)
print("A large dragon jumps out in front of you! ")
print("He opens his jaws and ...")
time.sleep(2)
friendly_cave = random.randint(1,4)
if choosen_cave == str(friendly_cave):
print("Gives you his treasure!")
else:
random_cave = random.choice(caves)
print(str(random_cave))

while True:
display_intro()
cave_number = choose_cave()
check_cave(cave_number)
try_again = input("Do you want to try again ? (Y for yes / N for no) : ")
if try_again.lower() == "n":
break
44 changes: 44 additions & 0 deletions python/project_lottery.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#IMPORT RANDOM MODULE
import random

#CREATE VARIABLE
user_list = []
random_list = []
user_value = 0
random_value = 0
count = 0
matches = 0

#GET VALUES FROM THE USER INTO A LIST
user_list.append(int(input("Insert number 1 : ")))
user_list.append(int(input("Insert number 2 : ")))
user_list.append(int(input("Insert number 3 : ")))
user_list.append(int(input("Insert number 4 : ")))
user_list.append(int(input("Insert number 5 : ")))
print("\n")

#GET RANDOM NUMBERS INTO A LIST
random_list.append(random.randrange(1,50))
random_list.append(random.randrange(1,50))
random_list.append(random.randrange(1,50))
random_list.append(random.randrange(1,50))
random_list.append(random.randrange(1,50))

#DISPLAY THE USER ENTRIES
print("User number :",end = " ")
for user_value in user_list:
print(user_value,end = " ")
print("\n")

#DISPLAY THE LOTTERY NUMBERS
print("Lottery numbers : ",end = " ")
for random_value in random_list:
print(random_value,end = " " )

#LOOK FOR MATCHING VALUES IN BOTH LISTS
for count in range (5):
if user_list[count] == random_list[count]:
matches +=1

#DISPLAY NUMBER OF MATCHES
print("\n\nYou have",matches,"matches")
52 changes: 52 additions & 0 deletions python/simple_calculator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#---------------------CREATE VARIABLES------------------------
Operator = ""
Num1 = 0
Num2 = 0
while True:
#--------------------GET VALUES FROM THE USER--------------------
print("Enter the operator from the above list : \n","\t Addition = + \n","\t Substraction = - \n","\t Multiplication = * \n", "\t Division = / \n","\t Power = ** \n")
Num1 = int(input("Enter the number 1 : "))
Num2 = int(input("Enter the number 2 : "))
Operator = str(input("Enter the Operator : " ))
#----------------------SIMPLE FUNCTIONS---------------------------
def Addition (Num1,Num2):
"This for the addition of two numbers"
Ans = Num1+Num2
return Ans
def Substraction (Num1,Num2):
"This for the substraaction of two numbers"
Ans = Num1-Num2
return Ans

def Multiplication(Num1,Num2):
"This for the multiplication of two numbers"
Ans = Num1*Num2
return Ans

def Division (Num1,Num2):
"This for the division of two numbers"
Ans = Num1/Num2
return Ans

def Power (Num1,Num2):
"This for the power of two numbers"
Ans = Num1**Num2
return Ans

#----------------------PROCESS AND DISPLAY------------------------
if Operator == '+':
print ("The addition of the two numbers are :", Addition(Num1,Num2))
elif Operator == '-':
print ("The substraction of the two numbers are :", Substraction(Num1,Num2))
elif Operator == '*':
print ("The multiplication of the two numbers are :", Multiplication(Num1,Num2))
elif Operator == '/':
print ("The division of the two numbers are :", Division(Num1,Num2))
elif Operator == '**':
print ("The power of the two numbers are :", Power(Num1,Num2))
else:
print("Please enter the correct operator and opperands")