diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 000000000..6f302b9e7 Binary files /dev/null and b/.DS_Store differ diff --git a/ASCII Initials.py b/ASCII Initials.py new file mode 100644 index 000000000..f2502a6db --- /dev/null +++ b/ASCII Initials.py @@ -0,0 +1,8 @@ +print(""" +IIIII A GGGGGGGGGGGGGG L + I A A GG L + I AAAAAAA GGG GGGGGGGG L + I A A GGG L + I A A GGGGGGGGGGGGGGGG LLLLLLLLLLB +IIIII +""") \ No newline at end of file diff --git a/Modules/.DS_Store b/Modules/.DS_Store new file mode 100644 index 000000000..7ff3af225 Binary files /dev/null and b/Modules/.DS_Store differ diff --git a/Modules/Module1/Module1.md b/Modules/Module1/Module1.md index 06a6d487d..f4bd85a20 100644 --- a/Modules/Module1/Module1.md +++ b/Modules/Module1/Module1.md @@ -181,7 +181,7 @@ You may update both simultaneously from Visual Studio by selecting. What is the difference between Git and GitHub? - - Answer: + - Answer:The difference between Git and GitHub is that Git What is the difference between a git commit and a git push? @@ -193,7 +193,7 @@ What is the difference between a pull, and an upstream pull? What part of these instructions was unclear or incomplete? - - Answer: + - Answer:none Type down any class notes below this sentence: diff --git a/Modules/Module3/Module3.md b/Modules/Module3/Module3.md index 44d718e32..157271c8b 100644 --- a/Modules/Module3/Module3.md +++ b/Modules/Module3/Module3.md @@ -96,24 +96,27 @@ print(type(age)) What is the difference between "42" and 42. - - Answer: + - Answer: String and Intiger Define the boolean operators: >, <, ==, >=, <= - - Answer: + - \ How do you address an index in an list? Write a python code that assigns 34 to a new variable by accessing the value stored in: arr = [4, 3, -1, 4, 34] - - Answer: + - Answer: arr = [4, 3, -1, 4, 34] +>>> arr [4] +34 What is the first index of a list? Why? - - Answer: + - Answer:0 + Because of the binary code Provide an original example of a null value. It must prove your understanding of the concept. - - Answer: + - Answer: My grade is null. Type down any class notes below this sentence: diff --git a/Modules/Module4/Ignacio-Guzman-Ticketera.py b/Modules/Module4/Ignacio-Guzman-Ticketera.py new file mode 100644 index 000000000..71105707a --- /dev/null +++ b/Modules/Module4/Ignacio-Guzman-Ticketera.py @@ -0,0 +1,30 @@ + +print("Welcome to Rauw Alejandro Concert") +print("The cost of each seat is a follow: VIP= 200$, Arena/Nivel Principal = 95$, Club Seat = 85$") + +VIP = int(input("How many tickets sold for VIP?")) + +ArenaNivelPrincipal = int(input("How many tickets sold for Arena/Nivel Principal?")) + +ClubSeats = int(input("How many tickets sold for Club Seat?")) + + + +def TicketsSold(VIP, ArenaNivelPrincipal, ClubSeats): + print(f"The cost of all of the VIP tickets sold were: {int(VIP) * 200}") + print(f"The cost of all of the Arena/Nivel Principal tickets sold were: {int(ArenaNivelPrincipal) * 95}") + print(f"The cost of all of the Clubs Seat tickets sold were: {int(ClubSeats) * 85}") + + + +TicketsSold(VIP, ArenaNivelPrincipal , ClubSeats) +sold_VIP = VIP * 183 +sold_ANP = ArenaNivelPrincipal * 160 +sold_CL = ClubSeats * 150 + + +def TicketsTotal(sold_VIP, sold_ANP, sold_CL): + print(f"The total of tickets sales is: {int(sold_VIP) + int(sold_ANP) + int(sold_CL)}") + + +TicketsTotal(sold_VIP, sold_ANP, sold_CL) \ No newline at end of file diff --git a/Modules/Module4/Module4.md b/Modules/Module4/Module4.md index afc1e494f..3c59c93a8 100644 --- a/Modules/Module4/Module4.md +++ b/Modules/Module4/Module4.md @@ -49,7 +49,8 @@ def greetStudent(name): greetStudent(name) ``` >José D. Quintana Rivera - +def greetstudent(name): + print(f"Hello{name}!")
@@ -136,7 +137,7 @@ Evaluate the following code. Is the code written correctly? What would be the co print('This message has a syntax error!") print(Churrigueresco) - - Answer: + - Answer: C Evaluate the following code. Is the code written correctly? What would be the correct code? someNumber=360 @@ -149,6 +150,7 @@ Define a function that takes 2 or more string parameters and prints a single lin - Answer: + Refer to this documentation webpage and google for the exercises below: diff --git a/Modules/Module4/Module4.py b/Modules/Module4/Module4.py new file mode 100644 index 000000000..9e89738db --- /dev/null +++ b/Modules/Module4/Module4.py @@ -0,0 +1,17 @@ +# print("What did you have for breakfest?") +# meal = "waffles" +# print(meal) +# print("What was your lunch?") +# meal = "Chicken Tenders" +# print("What was your dinner?") +# meal = "Hamburger with fries" +# print(meal) +def greetstudent(name): + print(f"Hello{name}"!") +greetstudent(Ignacio Guzman) + +myName:str = "Ignacio Guzman" +myAge:int = 15 + +width = int(input(" What is the width of the square:")) +myheigh = \ No newline at end of file diff --git a/Modules/Module5/Boolean expresions.py b/Modules/Module5/Boolean expresions.py new file mode 100644 index 000000000..ec53a529c --- /dev/null +++ b/Modules/Module5/Boolean expresions.py @@ -0,0 +1,35 @@ +import random +print("Welcome to rock paper scissors game") +RPS = ["rock", "paper", "scissors"] + +playerChoice = input("Lets play . Choose one: rock, paper, scissors") + +computerChoice = random.choice(RPS) +print(f"Computer selected: {computerChoice}") +print(f"Player selected: {playerChoice}") + +if(playerChoice == computerChoice): + print("You tied") + +elif(playerChoice == "rock" and computerChoice == "scissors"): + print("rock crushes scissor. You Win!") + +elif(playerChoice == "rock" and computerChoice == "paper"): + print("You Lost") + +elif(playerChoice == "paper" and computerChoice == "rock"): + print("You Won") + +elif(playerChoice == "scissors" and computerChoice == "paper"): + print("You Won") + +elif(playerChoice == "scissors" and computerChoice == "rock"): + print("You Lost") + +elif(playerChoice == "paper" and computerChoice == "scissors"): + print("You Lost") + +else: + print("something isnt right, maybe try again") + + diff --git a/Modules/Module5/Ignacio-Guzman-magic.py b/Modules/Module5/Ignacio-Guzman-magic.py new file mode 100644 index 000000000..d3d887ec2 --- /dev/null +++ b/Modules/Module5/Ignacio-Guzman-magic.py @@ -0,0 +1,33 @@ +import random +print("Welcome to the Magic 8-Ball Game") +Player_name = input("What is your name?") +print(f"Hello {Player_name} ! Welcome to the Magic 8-Ball Game") +Player_question = input ("What do you want to ask me?") +print(f"{Player_name} ask {Player_question}") +random_number = random.randint(1,12) +if random_number == 1 : + print("Yes - definitely") +elif random_number == 2: + print("It is decidebly so.") +elif random_number == 3: + print("Without a doubt") +elif random_number == 4: + print("Reply hazy, tray again.") +elif random_number == 5: + print("Ask Again Later") +elif random_number == 6: + print("Better not tell you now.") +elif random_number == 7: + print("My sources say NO.") +elif random_number == 8: + print("Outlook not so good.") +elif random_number == 9: + print("Very doubtful.") +elif random_number == 10: + print("Not Today") +elif random_number == 11: + print("I think so") +elif random_number == 12: + print("Tomorrow") +else: + print("There was an error") \ No newline at end of file diff --git a/Modules/Module5/Ignacio-Guzman-simpsonshipping.py b/Modules/Module5/Ignacio-Guzman-simpsonshipping.py new file mode 100644 index 000000000..d1362552b --- /dev/null +++ b/Modules/Module5/Ignacio-Guzman-simpsonshipping.py @@ -0,0 +1,11 @@ +print("Welcome to Simpson Shipping") +weight:float = float(input("What is the weight of your package:")) +#ground shipping +if (weight == 2 and weight < 2): + cost_ground = 2 and weight * 1.75 + 20 + print("Ground Shipping $", float(cost_ground)) +elif (weight == 2 > ) + + + + \ No newline at end of file diff --git a/Modules/Module5/Module5.md b/Modules/Module5/Module5.md index c868f02f7..c0a53cf0b 100644 --- a/Modules/Module5/Module5.md +++ b/Modules/Module5/Module5.md @@ -81,9 +81,15 @@ print(f"Computer selected: {computerChoice}") Give a python example for each logic operator in the module image. - Answers: - - OR: - - AND: - - NOT: + - OR: X = 35 + if(x > 20 or x < 30) + print("your number is 25"): + - AND: candies = 6 + if(candies > 7 or < 5 ) + print("you have little candies"): + - NOT: X = 32 + if not (x > 29 and x < 32): + print("Your number is 32"): Type down any class notes below this sentence: diff --git a/Modules/SourceTree/.DS_Store b/Modules/SourceTree/.DS_Store new file mode 100644 index 000000000..5008ddfcf Binary files /dev/null and b/Modules/SourceTree/.DS_Store differ diff --git a/Projects/ASCII Initials.py b/Projects/ASCII Initials.py new file mode 100644 index 000000000..67b9af50c --- /dev/null +++ b/Projects/ASCII Initials.py @@ -0,0 +1,8 @@ +print(""" +IIIII A GGGGGGGGGGGGGG L + I A A GG G L + I AAAAAAA GGG L + I A A GGG L + I A A GGGGGGGGGGGGGGGG LLLLLLLLLL +IIIII +""") \ No newline at end of file diff --git a/Projects/Ignacio-Guzman-Hangman.py b/Projects/Ignacio-Guzman-Hangman.py new file mode 100644 index 000000000..798940b42 --- /dev/null +++ b/Projects/Ignacio-Guzman-Hangman.py @@ -0,0 +1,63 @@ +import random +word_list = ["buchipluma", "guasibiri", "glopeta", "acicalao", "masucamba", "sandungueo", "pichaera", +"feca", "blinblineo", "banshee" ] +def display_hangman(tries): + stages = [ """ + -------- + | | + | O + | /|\\ + | | + | / \\ + - + """, + """ + -------- + | | + | O + | /|\\ + | | + | / + - + """, + """ + -------- + | | + | O + | /|\\ + | | + | + - + """, + """" + -------- + | | + | O + | /| + | | + | + - + """, + """ + -------- + | | + | O + | | + | | + | + - + """, + """ + -------- + | | + | O + | + | + | + - + """, + """ + -------- + | | + | + | \ No newline at end of file diff --git a/Projects/Ignacio-Guzman-Jump.py b/Projects/Ignacio-Guzman-Jump.py new file mode 100644 index 000000000..9a4888189 --- /dev/null +++ b/Projects/Ignacio-Guzman-Jump.py @@ -0,0 +1,8 @@ +planets = ["Mercury" , "Venus"] +rel_gravity = [2.65, 1.11, 1, 2.64, 0.40, 0.94, 1.13, 0.88] + +print("Jumpion on a diffrent planet ") +Jump = float(input("What is your jump length? (meters)? ") +Planet = input(f"Choose a planet: {planets}") + + defcalculate lenght diff --git a/Projects/Ignacio-Guzman-space.py b/Projects/Ignacio-Guzman-space.py new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/Projects/Ignacio-Guzman-space.py @@ -0,0 +1 @@ + diff --git a/Projects/Ignacio-Guzman.py b/Projects/Ignacio-Guzman.py new file mode 100644 index 000000000..8ca185aa2 --- /dev/null +++ b/Projects/Ignacio-Guzman.py @@ -0,0 +1,22 @@ +planets = ("Mercury", "Venus", "Earth","Mars", "Jupiter","Saturn","Uranus" , "Neptune") +g_ms2 = [3.7, 8.87 ,9.81, 3.711, 24.79, 10.44 , 8.69, 11.5] + +print("Calculate your weight in a diffrent planet") + +myWeigh = int(input("What is your weight (pounds)?") +myplanet = input(f"Select a planet from the list: {Planets}") + +def calculateWeight(planet, mass ) : + print(f"/nEarth mass in pounds is : {mass}) + +w_kg= mass / 2.2046 + print(f"Mass in kg : {w_kg}") + +n_lb = 4.45 + +planet_index = planet.index(planet) +print(f"Weight in {planets[planet_index]}mmis {w_kg * g_ms[planet_index]) / n_lb} lb") + + +calculateWeight(myPlanet , myWeigh) + diff --git a/Projects/Ignacio-Guzman.snake.py b/Projects/Ignacio-Guzman.snake.py new file mode 100644 index 000000000..aa1f81a7a --- /dev/null +++ b/Projects/Ignacio-Guzman.snake.py @@ -0,0 +1,128 @@ +import asyncore +from asyncore import loop +from pickle import TRUE +from random import random +from turtle import update, width +import pygame +ig + +pygame.init() + +blue=(19,109,178) #game +green=(155,252,10) #backround +orange=(246,97,33) #food +yellow=(253,253,10) #score +violet= (107,10,253)#snake +dis_width = 400 +dis_height = 400 + + +dis_width = 400 +dis_height = 300 + +dis=pygame.display.set_mode((dis_width, dis_height)) + +pygame.display.set_caption("Snake Game by ML") +game_over =False + +clock = pygame.time.Clock() +snake_speed = 15 +snake_block = 10 + + +font_style = pygame.font.SysFont(None,50) + +score_font = pygame.font.SysFont(None, 25) + +def My_Score(score) : + value = score_font.render ("Your Score:" + str(score), True, yellow) + dis.blit(value, [0, 0]) + + +def my_snake(snake_block, snake_list): + for x in snake_list: + pygame.draw.rect(dis, violet , [x[0], x [1] , snake_block,snake_block]) + +def message(msg,color): + mesg = font_style.render(msg, True, color) + dis.blit(mesg, [dis_width/10, dis_height/2]) + + +def gameloop(): + game_over = False + game_close = False + + + x1= dis_width/2 + y1=dis_height/2 + + x1_change = 0 + y1_change = 0 + + snake_List = [] + length_of_snake = 1 + + + foodx = round(random.ranrange(0, dis_width - snake_block) / 10) * 10 + foody = round(random.ranrange(0, dis_height - snake_block) / 10) * 10 + + + + + + while not game_over: + while game_close == True: + dis.fill(green) + message("you lost Press Q-Quit or P-Play Again") + pygame.display.update() + + + for event in pygame.event.get(): + if event.type == pygame.QUIT: + game_over = True + if event.type == pygame.KEYDOWN: + if event.key == pygame.K_LEFT: + x1_change = -10 + y1_change = 0 + elif event.key == pygame.K_RIGHT: + x1_change = 10 + y1_change = 0 + elif event.key == pygame.K_UP: + y1_change = -10 + x1_change = 0 + elif event.key == pygame.K_DOWN: + y1_change = 10 + x1_change = 0 + + if x1 >= dis_width or x1 or y1 >= dis_height or y1 <0: + game_close = True + + + x1 += x1_change + y1 += y1_change + dis.fill(green) + pygame.draw.rect(dis, orange,[foodx, foody, snake_block, snake_block]) + + snake_head = [] + snake_head.append(x1) + snake_head.append(y1) + snake_List.append(snake_head) + if len(snake_List) > length_of_snake: + del snake_List[0] + + for x in snake_List[: -1]: + if x == snake_head: + game_close = True + + my_snake(snake_block, snake_List) + My_Score(length_of_snake -1) + pygame.display.update() + + if x1 == foodx and y1 == foody: + foodx = round(random.randrange(0, dis_width - snake_block) / 10)* 10 + foody = round(random.randrange(0, dis_height - snake_block) / 10)* 10 + length_of_snake += 1 + clock.tick(snake_speed) + pygame.quit() + quit() +gameloop() \ No newline at end of file diff --git a/Projects/Projectile-Motion/Ignacio-Guzman-Project-Motion.py/Ignacio-Guzman-ProjectileMotion.py b/Projects/Projectile-Motion/Ignacio-Guzman-Project-Motion.py/Ignacio-Guzman-ProjectileMotion.py new file mode 100644 index 000000000..2e0dc53b7 --- /dev/null +++ b/Projects/Projectile-Motion/Ignacio-Guzman-Project-Motion.py/Ignacio-Guzman-ProjectileMotion.py @@ -0,0 +1,20 @@ +import math +gun = "GLOCK17" +caliber = "9x19mm" +ammunition = "PBB gzh" +velocity_ms= 560 + +Building = "Caribean Sea View" +BuildingHeight = 334 + + +gravity_Ms = 9.81 + + + +time_s = math.sqrt ((2 * 334) / 9.81) +distance = (30 * 68) + +print(f"The gun selected was "GLOCK17") +print(f"The caliber selected was"9x19mm ") +"Caribean Sea View" diff --git a/Projects/Projectile-Motion/expermentaldata.py b/Projects/Projectile-Motion/expermentaldata.py new file mode 100644 index 000000000..2bbeb3086 --- /dev/null +++ b/Projects/Projectile-Motion/expermentaldata.py @@ -0,0 +1,52 @@ +import math +import os +from pathlib import Path +from ExperimentalData import ExperimentalData +import json + +#"gun" = "GLOCK17" +#"caliber" = "9x19mm" +#"ammunition" = "PBB gzh" +#"velocity"= 560 +#"building" = "Caribean Sea View" +#"buildingheight" = 334 +#"gravity" = 9.81 + +#Estan las calculaciones aqui y las listas de los planetas con sus gravedades +def projectilefunction(experimentalData: ExperimentalData): + planets = ["Neptune", "Urnanus", "Earth", "Saturn", "Jupiter", "Mars", "Venus", "Mercury"] + gravity = [3.7, 8.87, 9.81, 3.711, 24.79, 10.44, 8.69, 11.15] + + planets= planets.index(experimentalData.planet) + + time = math.sqrt((2 * experimentalData.buildinheight) / gravity[planets]) + distance = (experimentalData.velocity * time) + print(f"The gun i choose was the {experimentalData.gun} the ammunition is {experimentalData.ammunition}, the caliber is {experimentalData.caliber}, the velocity is {experimentalData.velocity} it will be at the {distance} at {time} and it will be shot at {experimentalData.building} that has a height of {experimentalData.buildinheight}") + print(f"The {experimentalData.planet} which has {gravity[planets]} is where this will be taken place.") +experimentalData = ExperimentalData("Glock17", "9x19mm", "PBB", 560, "Carrebean Sea view", 334, "Earth") +#Estamos cogiendo los experimentos en cada planeta que escogi +myDataSet = [ +ExperimentalData("Glock17","9x19mm","PBB ", 560, "Caribean Sea view",334,"Neptune"), +ExperimentalData("Glock17","9x19mm","PBB ", 560, "Caribean Sea view",334,"Urnanus"), +ExperimentalData("Glock17","9x19mm","PBB ", 560, "Caribean Sea view",334,"Saturn"), +ExperimentalData("Glock17","9x19mm","PBB ", 560, "Caribean Sea view",334,"Jupiter"), +ExperimentalData("Glock17","9x19mm","PBB ", 560, "Caribean Sea view",334,"Mars"), +] + + +#Aqui estamos pritintiando el data set y llamandolo por seccion +for data in myDataSet: + print("\n---------------------------------------------------------------------\n") + projectilefunction(data) + myOutputPath = Path(__file__).parents[0] + myOutputFilePath = os.path.join(myOutputPath, "proyectileMotion.json") + print(myOutputFilePath) +with open(myOutputFilePath, "w") as outfile: + json.dump([data.__dict__ for data in myDataSet], outfile) + deserialize = open(myOutputFilePath) + experimentJson = json.load(deserialize) + myOutputPath = Path(__file__).parents[0] +for e in experimentJson: + print("\n-------------------------------------------------\n") + projectilefunction(ExperimentalData(**e)) + \ No newline at end of file diff --git a/Projects/Web-Scraping/ignacio-guzman.py b/Projects/Web-Scraping/ignacio-guzman.py new file mode 100644 index 000000000..b8ab1eeaa --- /dev/null +++ b/Projects/Web-Scraping/ignacio-guzman.py @@ -0,0 +1,9 @@ +import bs4 +examplefile = open ("example.htmml") +exampleSou = bs4.BeatifulSoup(examplefile.read(), "html.parser") +elems = exampleSoup..select("#author") +type(elems) +print (len(elems)) +type(elems{0}) +str(elem{)} +print(elems){0},getText() \ No newline at end of file diff --git a/Projects/Web-Scraping/we-scarping5.py b/Projects/Web-Scraping/we-scarping5.py new file mode 100644 index 000000000..f0a1e237a --- /dev/null +++ b/Projects/Web-Scraping/we-scarping5.py @@ -0,0 +1,25 @@ + +import requests +import bs4 + +website = requests.get("https://forecast.weather.gov/MapClick.php?lat=18.3808&lon=-65.9574#.Yks0w27MJQI") +forecast = bs4.BeautifulSoup(website.content , "html.parser") +sevenDay = forecast.find(id="seven-day-forecast") +forecast_items = sevenDay.find_all(class_="tombstone-container") +tonight = forecast_items[1] +# period = tonight.find(class_="period-name").get_text() +# print(period) +print(tonight.prettify()) + print (tonight,prettify()) +R11 +period - tonight. find(class_-"period-namelD-get_text() +12 +print (period) +13 +14 +short desc = tonight. find(class_-"short-desc"').get text() +print (short desc) +25 +temp = tonight. find(class_-"low low-temp").get_text() +16 +print (temp) diff --git a/Projects/Web-Scraping/web-scarping04-ignacio-guzman.py b/Projects/Web-Scraping/web-scarping04-ignacio-guzman.py new file mode 100644 index 000000000..70de15f63 --- /dev/null +++ b/Projects/Web-Scraping/web-scarping04-ignacio-guzman.py @@ -0,0 +1,11 @@ +import requests +import bs4 +res = requests.get('https://www.sanignacio.pr/sobre-csi/historia-del-colegio') +res.raise_for_status() +SanIgnaciopr = bs4.BeautifulSoup(res.content, 'html.parser') +elems = SanIgnaciopr.select('p') +print(type(SanIgnaciopr)) +print(len(elems)) +print(str(elems)) +print(elems[2].getText()) +print(elems[3].getText()) \ No newline at end of file diff --git a/Projects/Web-Scraping/web-scraping01-ignacio-guzman.py b/Projects/Web-Scraping/web-scraping01-ignacio-guzman.py new file mode 100644 index 000000000..33a1ba740 --- /dev/null +++ b/Projects/Web-Scraping/web-scraping01-ignacio-guzman.py @@ -0,0 +1,7 @@ +from cgi import print_directory +import requests +res = requests.get(https://www.gutenberg.org/ebooks/67637) +type(res) +res.status_code == requests.code.ok +len(res.text) +print \ No newline at end of file diff --git a/Projects/Web-Scraping/web-scrapinng03-ignacio-guzman.py b/Projects/Web-Scraping/web-scrapinng03-ignacio-guzman.py new file mode 100644 index 000000000..02289fd6a --- /dev/null +++ b/Projects/Web-Scraping/web-scrapinng03-ignacio-guzman.py @@ -0,0 +1,16 @@ +import requests +import bs4 + +res = requests.get("https://sanignacio.pr") +res.raise_for_status() + +SanIgnaciopr = bs4.BeautifulSoup(res.text, "html.parser") + +elems = SanIgnaciopr.select("title") + +print(type(SanIgnaciopr)) +print(len(elems)) + +print(str(elems)) + +print(elems[0].getText()) \ No newline at end of file diff --git a/Projects/Web-Scraping/webscrapping02 Ignacio-Guzman02.py b/Projects/Web-Scraping/webscrapping02 Ignacio-Guzman02.py new file mode 100644 index 000000000..acec818c1 --- /dev/null +++ b/Projects/Web-Scraping/webscrapping02 Ignacio-Guzman02.py @@ -0,0 +1,7 @@ +import requests +res = requests.get(https://www.gutenberg.org/ebooks/67637) +res.raise_for_status() +playfile = open(The History of the Manners and Customs of Ancient Greece Volume II (of 3)) +for chunk in res.iter_content(10000): + playFile.write(chunk) +playFile.close() \ No newline at end of file diff --git a/Projects/igancio-guzman-hangman.py b/Projects/igancio-guzman-hangman.py new file mode 100644 index 000000000..097984928 --- /dev/null +++ b/Projects/igancio-guzman-hangman.py @@ -0,0 +1,134 @@ +import random +word_list = ["CelestinaCordero", "AdolfinVillanueva ", "SylviaVillard ", "IvonneCabrera", "RutFernández ", "EneidGomez", "DomingaCruz", "JuliaBurgos", "LuisaCapetillo", "FelisaRincón" ] + +def get_word(word_list): + word = random.choice(word_list) + return word.upper() + +def play(word): + word_completion = "_" * len(word) + guessed = False + guessed_letters = [] + guessed_words = [] + tries = 6 + print("Lets play Hangman") + print("Theme: Las Mujueres Ilustres De Puerto Rico") + print(display_hangman(tries)) + print(word_completion) + print("\n") + while not guessed and tries > 0: + guess = input("Guess a letter or word").upper() + if len(guess) == 1 and guess.isalpha(): + if guess in guessed_letters: + print("You already tried", guess) + elif guess not in word: + print(guess, "Isnt in the word :(") + tries -= 1 + guessed_letters.append(guess) + else: + print("Nice one", guess, "is in the word") + guessed_letters.append(guess) + word_as_list = list(word_completion) + indices = [i for i, letter in enumerate(word) if letter == guess] + for index in indices: + word_as_list[index] = guess + word_completion = "".join(word_as_list) + if "_" not in word_completion: + guessed = True + elif len(guess) == len(word) and guess.isalpha(): + if guess in guessed_words: + print("You already tried", guess, "!") + elif guess != word: + print(guess, "Is not the word.") + tries -= 1 + guessed_words.append(guess) + else: + guessed = True + word_completion = word + else: + print("Ivalid input") + print(display_hangman(tries)) + print(word_completion) + print("\n") + + if guessed: + print("Good job, you guessed the word") + else: + print("You ran of tries. The word was" + word + "Maybe next time") + +def display_hangman(tries): + stages = [ """ + -------- + | | + | O + | /|\\ + | | + | / \\ + - + """, + """ + -------- + | | + | O + | /|\\ + | | + | / + - + """, + """ + -------- + | | + | O + | /|\\ + | | + | + - + """, + """" + -------- + | | + | O + | /| + | | + | + - + """, + """ + -------- + | | + | O + | | + | | + | + - + """, + """ + -------- + | | + | O + | + | + | + - + """, + """ + -------- + | | + | + | + | + | + - + """, + ] + return stages[tries] +def main(): + word = get_word(word_list) + play (word) + while input("Again? (Y/N)").upper() == "Y": + wprd = get_word(word_list) + play(word) + + +if __name__ == "__main__": + main()