0
How to add reset option to a calculator
Need to add reset option by clicking $ sign. How can do it? After that the programme should go to the starting area. https://code.sololearn.com/cOqkietecV4z/?ref=app
5 Antworten
+ 5
Jude Maria Bevan ,
before using:
os.system("clear")
we have to import this module:
import os
+ 2
if by reset you mean clearing previous output then you can do it the following way, 
 if choice == "quot;:
    os.system("clear")  
    continue
(for mac and linux use "clear", for windows use "cls")
0
It's in python is it okay to put clear
0
It's comming intendation error after inserting that code 
https://code.sololearn.com/cqA8nNf60VUQ/?ref=app
0
My version:
from decimal import*
d=Decimal
def apply(*nums,opp):
	nums = tuple(map(d,map(float,nums)))
	res = nums[0]
	for n in nums[1:]:
		res = d(eval(f'{res}{opp}{n}'))
	return str(res)
clear = lambda: __import__('os').system('cls' if __import__('os').name!='posix' else 'clear')
while True:
	choice = input('''
• Select Operation:
   [1]     Add:    '+'
   [2]  Subtract:  '-'
   [3]  Multiply:  '*'
   [4]   Divide:   '/'
   [5]    Power:   '^'
   [6]   Reset:    '#x27;
   [7]    Exit:    '#'
• Enter the choice: ''')
	if choice in '+-*/^':
		nums = input('''
• Enter numbers
    separated 
      with
     commas: 
[:)+> ''').split(',')
		res = f"{f'{nums[0]}'}{''.join(f'{choice} {i} 'for i in nums[1:])}= {apply(*nums,opp=choice)}"
		print(res)
	elif choice=='#x27;:
			clear()
	elif choice=='#':
			exit('\n• Terminating ... ')



