<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: JFG-0</title>
    <description>The latest articles on DEV Community by JFG-0 (@jfg0).</description>
    <link>https://dev.to/jfg0</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F842743%2F10254f34-8bbe-45a4-9903-6a1c506391e5.png</url>
      <title>DEV Community: JFG-0</title>
      <link>https://dev.to/jfg0</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jfg0"/>
    <language>en</language>
    <item>
      <title>The first actual Python program I want to show</title>
      <dc:creator>JFG-0</dc:creator>
      <pubDate>Wed, 06 Apr 2022 03:05:35 +0000</pubDate>
      <link>https://dev.to/jfg0/the-first-actual-python-program-i-want-to-show-285d</link>
      <guid>https://dev.to/jfg0/the-first-actual-python-program-i-want-to-show-285d</guid>
      <description>&lt;p&gt;This is my final excersise from (Much appreciated) codecademy's CS101, a terminal game that applies a trivia in spanish, it creates a player and returns a score.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#create the trivia questions

import csv
from unicodedata import category
with open('D:/UX/01_Python_course/20220323_trivia_thor/preguntas_trivia.csv') as csv_file:
    csv_read = csv.reader(csv_file, delimiter= ',')
    trivia_list = list(csv_read)

marathon_list = []

def list_clean(list, new_list):
    for item in range(0, len(list)):
        list_to_work = trivia_list[item]
        check = 0 
        for i in range(0, len(list_to_work)):
            if list_to_work[i] != "":
                check += 1
            else:
                continue
        if check != 0: new_list.append(list[item])

list_clean(trivia_list, marathon_list)
#print(marathon_list)

#Here lives the right answer generator
import csv
from unicodedata import category
with open('D:/UX/01_Python_course/20220323_trivia_thor/preguntas_trivia.csv') as csv_file:
    csv_read = csv.reader(csv_file, delimiter= ',')
    trivia_list = list(csv_read)

correct_answers = dict()
for item in range(1, len(trivia_list)):
    correct_answers[str(trivia_list[item][0])] = str(trivia_list[item][-1])

#create a file that uses a class
class Scout:

    def __init__(self, name, age, achievements):
        self.name = name
        self.age = age
        self.achievements = achievements
        self.game_score = 0

    def __repr__(self) -&amp;gt; str: return "{name} es un caminante de Thor, tiene {age} años y su progresión actual es {achievement}".format(name = self.name, age = self.age, achievement = self.achievements)

    def update_score(self, attained_score):
        self.game_score = attained_score
        print('Muy bien {name_player}, tu puntaje de {score} se añadirá, gracias por participar!'.format(name_player = self.name, score = self.game_score))
#welcome

print("Bienvenido a la trivia de Thor, hoy conoceremos tu avance y nos dirás qué te parece el juego.\
    Ingresa tu nombre, quedará en minúsculas para efectos prácticos!")
nombre = input()
print("Hola " + nombre.lower())

#request age
edad = ""
status = False
print('ingresa tu edad en números!')

while status == False:
    ingresar_edad = input()
    try:
        if type(int(ingresar_edad)) == int:
            status = True 
    except:
        print("Tratemos de nuevo")
    finally:
            continue
print("Tu edad es " + str(ingresar_edad) + " años")

edad = ingresar_edad

print("De acuerdo, cuál es tu última progresión?")
achievements = {"a" : "Busqueda", "b": "encuentro", "c" : "desafio", "d" : "IDO"}

for key, value in achievements.items():
    print(key + " " + value)

#puede irse_ print(str(achievements.items()) + " \elige por favor una letra")
print("elige por favor una letra")

achievement = input()

if achievement in achievements.keys():
    achievements[achievement]
else :
    print("intentemos de nuevo")
    achievement = input()

achievement = achievements[achievement]

player = Scout(nombre, edad, achievement)
print(player)

#Aqui comienza el juego en forma
print("De acuerdo, comencemos")

#Pose the question and match the right answer
initial_score = 0
def marathon(beginning_score):
    player_score = 0
    answer_options = ["a", "b", "c", "d"]
    question_count = 1
    for question in range(1,len(trivia_list)):
        print(trivia_list[question_count][0])
        def option_array():
            option_count = 1
            incise_count = 0
            for option in range(len(answer_options)):
                print(answer_options[incise_count] + "): " + trivia_list[question][option_count])
                option_count += 1
                incise_count += 1
        option_array()
        answer = input()
        if answer in answer_options == False:
            print("debe ser una de estas resputestas:")
            option_array()
        else:
            if answer.upper() == correct_answers[str(trivia_list[question_count][0])]:
                player_score += 1
                print('Muy bien, tu puntaje ahora es ' + str(player_score))
            else:
                print("Suerte en la siguiente pregunta!")
        question_count += 1
    print("Bien, tu puntaje final es " + str(player_score))
    beginning_score = player_score
    return beginning_score

marathon(initial_score)
print(initial_score)

print(player.update_score(initial_score))

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>learning</category>
      <category>python</category>
      <category>cs101</category>
    </item>
  </channel>
</rss>
