def start(): print(' Welcome, I\'m your smart calculator!') start_question = input(' Would you like to skip the start tips \n Continue to watch the tips?\n Enter\'Y\' or \'N\': ') if start_question == 'Y': help() else: wyta() def help(): import time ts = time.sleep print(' Hi, I\'m your smart calculator! And i can solve examples with:') ts(2) print(' \'+\' – Addition;') ts(1.3) print(' \'-\' – Subtraction;') ts(1.3) print(' \'*\' – Multiplication;') ts(1.3) print(' \'/\' – Division;') ts(1.3) print(' \'**\' – Exponentiation;') ts(1.3) print(' \'%\' – Interest calculation;') ts(1.3) print(' \'help\' – Call up the help menu.') ts(1.3) print(' The quit command works in all menus, which provide the ability to enter anything.') ts(2) wyta() # Continue def wyta(): import sys import math enter = input(' Indicate what action you want to solve the task: ') if enter == '+': a = float(input(' Enter the first number: ')) b = float(input(' Enter the second number: ')) c = a + b print(' Result: ' + str(c)) choice_to_leave_from_program() elif enter == '-': a = float(input(' Enter the first number: ')) b = float(input(' Enter the second number: ')) c = a - b print(' Result: ' + str(c)) choice_to_leave_from_program() elif enter == '*': a = float(input(' Enter the first number: ')) b = float(input(' Enter the second number: ')) c = a * b print(' Result: ' + str(c)) choice_to_leave_from_program() elif enter == '/': a = float(input(' Enter the first number: ')) b = float(input(' Enter the second number: ')) c = a / b print(' Result: ' + str(c)) choice_to_leave_from_program() elif enter == 'quit' or 'QUIT' or 'Quit' or 'QUit' or 'QUIt' or 'quiT' or 'qUit' or 'QuiT' or 'quiT': sys.exit() else: print('Unknown operation.') wyta() def choice_to_leave_from_program(): import time import sys ts = time.sleep choice = input('Will u try again? Send \'Y\' or \'N\': ') if choice == 'Y': print('') print('Okay!') print('') wyta() elif choice == 'HELP': help() else: ts(0.4) print('Script completion.') ts(0.4) print('Script completion..') ts(0.4) print('Script completion...') ts(0.4) print(' The scripts are complete.\n Program completed.') sys.exit() while 1 == 1: start()
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