Construeix un Chatbot

Prompt Engineering

Crea un chatbot senzill amb un diccionari de respostes. El bot ha de respondre a preguntes freqüents sobre el teu institut.

📌 View basic hints
  • Un diccionari {} emmagatzema parells clau:valor.
  • .get(clau, valor_per_defecte) evita errors si la clau no existeix.
  • while True crea un bucle infinit; usa 'break' per sortir.
Order the code blocks
pregunta = input('Tu: ').lower().strip()
resposta = respostes[pregunta]
while True:
}
break
resposta = respostes.get(pregunta, 'Ho sento, no entenc la pregunta.')
'adeu': 'Fins aviat!'
'menjador': 'El menjador és obert de 13h a 15h.',
'horari': 'Les classes comencen a les 8h i acaben a les 14:30h.',
if pregunta == 'adeu':
print('Bot: Hola! Escriu la teva pregunta (o "adeu" per sortir).')
print(f'Bot: {resposta}')
'hola': 'Hola! Sóc el bot del teu institut. Com puc ajudar-te?',
respostes = {
SEBACodiCAT