def main(): ####__________________________ BASE DE CONOCIMIENTO__________________________________________ nombre = ["Iphone", "Samsung", "Nexus", "Nokia Lumia", "BlackBerry", "Iphone", "Nokia Lumia", "BlackBerry", "Motorola", "BlackBerry", "Lenovo", "Samsung", "BlackBerry", "BlackBerry", "Huawei", "Lenovo", "Samsung", "Huawei", "Motorola", "BlackBerry", "BlackBerry", "Lumia", "Acer", "HP", "HTC"] modelo = ["7", "S7", "6", "930", "Q10", "6", "735", "Leap", "G3", "Z10", "K5", "C7", "Z3", "Q5", "GT3", "A1000", "A9", "Nova", "X2", "Leap", "Classic", "950XL", "Liquid Jade Primo", "EliteX3", "One M8"] mptrasera = ["12", "12", "13", "20", "8", "8", "6,7", "8", "13", "8", "13", "16", "5", "8", "13", "5", "13", "12", "13", "8", "8", "20", "21", "16", "4"] mpdelantera = ["7", "5", "2", "2", "2", "7", "5", "2", "8", "2", "5", "8", "2", "3", "3", "3", "5", "5", "3", "2", "2", "5", "8", "8", "5"] resolucion = ["HD", "QHD", "QHD", "HD", "QHD", "HD", "HD", "HD", "HD", "QHD", "HD", "HD", "QHD", "QHD", "HD", "QHD", "HD", "HD", "HD", "HD", "HD", "HD", "HD", "HD", "HD"] so = ["iOS", "Android", "Android", "Windows Phone 8", "BlackBerry 10", "iOS", "Windows Phone 8", "BlackBerry 10", "Android", "BlackBerry 10", "Android", "Android", "BlackBerry 10", "BlackBerry 10", "Android", "Android", "Android", "Android", "Android", "BlackBerry 10", "BlackBerry 10", "Windows Phone 10", "Windows Phone 10", "Windows Phone 10", "Windows Phone 10"] ram = ["2", "4", "3", "2", "2", "2", "1", "2", "1", "2", "2", "4", "2", "2", "2", "1", "3", "3", "2", "2", "2", "3", "3", "4", "2"] bateria = ["1960", "3000", "3220", "2420", "1800", "1810", "2200", "1800", "2470", "1800", "2750", "3300", "2500", "2180", "3000", "2000", "4000", "3020", "2300", "2800", "2515", "3300", "2800", "4150", "2600"] precio = ["2'799.900", "2'442.010", "2'263.900", "1'457.054", "520.000", "1'699.000", "588.444", "815.135", "649.900", "339.000", "499.900", "1'823.500", "189.000", "511.500", "619.900", "355.000", "1'509.500", "719.900", "488.500", "815.135", "1'457.054", "1'589.900", "1'046.090", "2'880.145", "757.915"] rom = ["32", "64", "64", "32", "16", "16", "8", "16", "16", "16", "16", "64", "8", "32", "16", "16", "32", "32", "32", "16", "16", "32", "32", "64", "16"] pantalla = ["4.7", "5.1", "6", "5", "3.1", "4.7", "4.7", "5", "5", "4.2", "5", "6", "2.8", "3.1", "5.5", "7", "5", "5", "4.7", "5", "3.2", "5.7", "5.5", "5.96", "5"] ####__________________________________________________________________________________________ respuesta = [] solucion = [] pregunta = 0 pos = 0 posibles = { 'y': 'Y', 'n': 'N', 'Y': 'Y', 'N': 'N'} caso = {0: resolucion[pregunta], 1: mptrasera[pregunta], 2: mpdelantera[pregunta], 3: bateria[pregunta], 4: ram[pregunta], 5: rom[pregunta], 6: pantalla[pregunta], 7: so[pregunta], 8: precio[pregunta] } while True: dialogo = ["Buscas la resolucion "+resolucion[pos]+" ?\t", "Buscas "+mptrasera[pos]+" megapixeles como camara trasera?\t", "Buscas "+mpdelantera[pos]+" megapixeles como camara delantera?\t", "Buscas una capacidad de "+bateria[pos]+"mAh en la bateria?\t", "Buscas una capacidad de procesamiento de "+ram[pos]+"GB?\t", "Buscas una capacidad de almacenamiento de "+rom[pos]+"GB?\t", "Buscas una pantalla de "+pantalla[pos]+" pulgadas?\t", "Buscas el sistema operativo "+so[pos]+"?\t", "Buscas un precio de "+precio[pos]+"?\t", "Responde 'Y' (para afirmar) o 'N' (para negar)\n"] res = raw_input(dialogo[pregunta]+dialogo[9]) try: resp = posibles[res] if resp == 'Y': solucion.append(caso[pregunta]) pregunta+=1 elif resp == 'N': if pos >= 25: print "\n\n El dispositivo que busca con esas caracteristicas no se encuentra en nuestra base de conocimiento \n\n \tGracias por usar nuestro software!\n" break else: pos+=1 if pregunta >= 9: print "\n\n\tEl dispositivo que busca es el "+nombre[pos]+" "+modelo[pos]+"\n\n" break except: print "ERROR!!! (Intente nuevamente)\n\n" main()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question