0

why is there a syntax error here and what is a syntax error

inp= input('select a mode as (calculator, game, or time)') calculator ={ #syntax error here > x = str(input('Please choose add, subtract, divide, or multiply, then choose 2 numbers')) add ={ z = int(input()) y = int(input()) print(z + y) } subtract ={ z = int(input()) y = int(input()) print(z - y) } divide ={ z = int(input()) y = int(input()) print(z / y) } multiply ={ z = int(input()) y = int(input()) print(z * y) } if x=='add': add if x=='subtract': subtract if x=='divide': divide if x=='multiply': multiply } game ={ import random a = random.choice(1, 10) x = int(input('Enter a number between 1 and 10')) if x==a: print('you got it right! The number was:', a) if x!=a: print('Sorry , you got it wrong. The number was: ', a) } time ={ import time as t a = t.now() print(a) } #################################################### if inp=='calculator': calculator if inp=='game': game if inp=='time': time else: print('Something went wrong. Please choose between calcultor, game, and time')

9th Jun 2018, 6:42 PM
Random test
3 ответов
+ 1
Hello, Random test there are many syntax error in the code: # In Python we do not define functions like this: add = { #... some code here } # but like this: def add(z, y): return z + y
9th Jun 2018, 6:52 PM
Ulisses Cruz
Ulisses Cruz - avatar
+ 1
If you want to define a class do it like this: class Calculator(object): #class declaration def add(x, y): # method declaration return x + y
9th Jun 2018, 7:02 PM
Ulisses Cruz
Ulisses Cruz - avatar
0
All right thx I'll try that
9th Jun 2018, 7:15 PM
Random test