Programa de construcción de tarjeta de memoria flash usando la clase en Python

Aquí, somos un programa de aplicación Python para construir tarjeta de memoria flash usando class y el enfoque de objetos en Python .

de tarjetas es una tarjeta virtual que contiene una palabra y su significado y class cada palabra, definimos una tarjeta de memoria flash separado. for de Python nos podría ayudar en la toma de este tipo de un programa.

Programa:

# We are making a flash card program, 
# in which each flashcard will consists
# of a word and its meaning
# Using class in python would make it easy
# We are defining a class 'card'
class card(object):
def __init__(self, word, meaning):
self.word = word
self.meaning = meaning
def getmeaning(self):
return self.meaning
def __str__(self):
return self.word + ' : ' + self.getmeaning()
# Defining a function for making a list of flashcards
def flashcard(flash, words, meanings):
flash.append(card(words, meanings))
return flash
lists = []
y = input("Want to add a flashcard? ")
while y == 'y' or y == 'Y':
word = input("Word you want to add to your Flashcards: ")
meaning = input("Meaning of the word in flashcard: ")
lists = flashcard(lists, word, meaning)
y = input("for adding another flashcard, press Y/y :")
print("----Following are the flashcards you made----")
for el in lists:
print(el)

salida

Want to add a flashcard? y
Word you want to add to your Flashcards: rescind
Meaning of the word in flashcard: cancel officially
for adding another flashcard, press Y/y :y
Word you want to add to your Flashcards: hegemony
Meaning of the word in flashcard: dominance over certain area
for adding another flashcard, press Y/y :y
Word you want to add to your Flashcards: brazen
Meaning of the word in flashcard: unrestrained by convention or proprierty
for adding another flashcard, press Y/y :n
----Following are the flashcards you made----
rescind : cancel officially
hegemony : dominance over certain area
brazen : unrestrained by convention or proprierty


Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *