Please Login in order to post a comment
without using eval(input())
num=list(map(int,input().split())) poly=input() subs='' for i in poly: if i=='x': subs+=f'{num[0]}' else: subs+=i a = list(subs.split(' ')) def po(st): if '**' in st: m=st.split("**") if '*' in m[0]: mm=m[0].split('*') return int(mm[0])*(int(mm[1])**int(m[1])) else: return (int(m[0])**int(m[1])) else: return st tot=po(a[0]) for i in range(len(a)-1): if a[i+1]=='+': tot+=int(po(a[i+2])) elif a[i+1]=='-': tot-=int(po(a[i+2])) else: tot=tot*1 print(tot==num[1])
Two lines
x,k=map(int,input().split()) print(eval(input())==k)
x, k = map(int, input().split()) print(eval(input())==k)
x, k = map(int, input().split()) result = eval(input()) print(result==k)
Seems like cookies are disabled on this browser, please enable them to open this website
without using eval(input())
Two lines
Two lines
Simple TWO LINE code
x, k = map(int, input().split()) print(eval(input())==k)