Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dragon game code #686

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
44 changes: 44 additions & 0 deletions Languages/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")
42 changes: 42 additions & 0 deletions Languages/Python/dragonGame.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