Descarga la aplicación para disfrutar aún más
Esta es una vista previa del archivo. Inicie sesión para ver el archivo original
# -*- coding: utf-8 -*- """ Created on Sat Nov 21 14:26:55 2020 @author: Jorge """ #%% #PREGUNTA 2.1: CONDICIONES BORDE n=int(input("Ingrese un número: ")) while n<0: n=int(input("Numero inválido. Ingrese otro número: ")) while n>=0: print(n) n-=1 #%% #PREGUNTA 2.2: VALIDACIONES precio=float(input("ingrese el precio del producto: ")) while precio<=0: precio=float(input("ingrese el precio del producto: ")) pago=float(input("ingrese cuanto se pagó: ")) while pago<precio: pago=float(input("ingrese cuanto se pagó: ")) print(int(pago - precio)) #%% # PREGUNTA 3.1 basket = {} more = 'si' while more == 'si': item = input('Introduce un artículo: ') price = float(input('Introduce el precio de ' + item + ': ')) basket[item] = price more = input('¿Quieres añadir artículos a la lista (si/no)? ') cost = 0 print('Lista de la compra') for item, price in basket.items(): print(item, '\t', price) cost += price print('Coste total: ', cost) #%% # PREGUNTA 3.2 #A def diccionario(): global personas personas = {} more = 'si' while more=='si': key = input('¿Qué dato quieres introducir? ') value = [] personas[key] = value more = input('¿Quieres añadir más información (si/no)? ') print("Las llaves creadas en tu diccionario personas son:",personas.keys()) #list(personas.keys())[0] #B def consultar(x): print(x.keys()) #C def agregarValores(x): y= 'si' while (y =='si'): for key in x: valor = input('que valor quieres agregar a la llave '+ key +'?') x[key].append(valor) y=input('¿Quieres añadir mas valores a la lista (si/no)? ') print(x)
Compartir