You've learned this already. ✅
Click here to view the next lesson.
Proyecto 1: Calculadora Básica
7. Funciones de Memoria
Una característica común en muchas calculadoras es la capacidad de almacenar y recuperar un solo número de la memoria. Implementemos esto.
memory = None # Initialize memory
# ... previous code ...
print("Enter 'M+' to store the current result into memory")
print("Enter 'MR' to retrieve the number from memory")
print("Enter 'MC' to clear the memory")
# ... within the main loop ...
elif user_input == 'M+':
memory = result # Assuming 'result' is where we store our latest calculated value.
print(f"Saved {result} to memory.")
elif user_input == 'MR':
if memory is None:
print("No value in memory.")
else:
print(f"Retrieved {memory} from memory.")
elif user_input == 'MC':
memory = None
print("Memory cleared.")
# ... rest of the code ...
7. Funciones de Memoria
Una característica común en muchas calculadoras es la capacidad de almacenar y recuperar un solo número de la memoria. Implementemos esto.
memory = None # Initialize memory
# ... previous code ...
print("Enter 'M+' to store the current result into memory")
print("Enter 'MR' to retrieve the number from memory")
print("Enter 'MC' to clear the memory")
# ... within the main loop ...
elif user_input == 'M+':
memory = result # Assuming 'result' is where we store our latest calculated value.
print(f"Saved {result} to memory.")
elif user_input == 'MR':
if memory is None:
print("No value in memory.")
else:
print(f"Retrieved {memory} from memory.")
elif user_input == 'MC':
memory = None
print("Memory cleared.")
# ... rest of the code ...
7. Funciones de Memoria
Una característica común en muchas calculadoras es la capacidad de almacenar y recuperar un solo número de la memoria. Implementemos esto.
memory = None # Initialize memory
# ... previous code ...
print("Enter 'M+' to store the current result into memory")
print("Enter 'MR' to retrieve the number from memory")
print("Enter 'MC' to clear the memory")
# ... within the main loop ...
elif user_input == 'M+':
memory = result # Assuming 'result' is where we store our latest calculated value.
print(f"Saved {result} to memory.")
elif user_input == 'MR':
if memory is None:
print("No value in memory.")
else:
print(f"Retrieved {memory} from memory.")
elif user_input == 'MC':
memory = None
print("Memory cleared.")
# ... rest of the code ...
7. Funciones de Memoria
Una característica común en muchas calculadoras es la capacidad de almacenar y recuperar un solo número de la memoria. Implementemos esto.
memory = None # Initialize memory
# ... previous code ...
print("Enter 'M+' to store the current result into memory")
print("Enter 'MR' to retrieve the number from memory")
print("Enter 'MC' to clear the memory")
# ... within the main loop ...
elif user_input == 'M+':
memory = result # Assuming 'result' is where we store our latest calculated value.
print(f"Saved {result} to memory.")
elif user_input == 'MR':
if memory is None:
print("No value in memory.")
else:
print(f"Retrieved {memory} from memory.")
elif user_input == 'MC':
memory = None
print("Memory cleared.")
# ... rest of the code ...