a calculator!
really helpful piece of equipment you can use for maths and science or even just playing around with numbers!! please like and comment
from Ciara and Ailbhe xx
thejoeman24 (31)
Nvm it does
AilbheCunningha (6)
of course it does we are coders ;)) you sound like my friend Joe! @thejoeman24
thejoeman24 (31)
The divided thingy doesnt work
AlexanderTarn (280)
you put in "=" instead of "+" in the input.
AilbheCunningha (6)
thanks babes!!! ill fix that now for u doll xx @AlexanderTarn
print("answer: " + str(eval(input("enter an equation to evaluate: "))))
@nithilan4 eval bad
@MarcusWeinberger eval bad
eval ok, if you use it properly @MarcusWeinberger
@Haaruun eval never okay, better alternatives. for any task. i dare u challenge me, please im bored
im up for a debate @MarcusWeinberger
whats wrong with eval? i'll find a sulution to all of them
@Haaruun okay then nice when would you ever need to use
eval
and couldn't use something better maybe more secure/robustAnd what are the security holes? @MarcusWeinberger
You can add a context object to it to isolate it form your program if you want,
import math; eval("math.pi", {"math":math})
@MarcusWeinberger@Haaruun with using user input. it can be messed with and the program could be exploited
@Haaruun and that's not what i meant. i mean when u have to use eval with input to get something dynamic or whatever like op did
Thats why you can control the context so they dont ruin the rest of the code @MarcusWeinberger
And just use proper error handling like the rest of the user input you get @MarcusWeinberger
@Haaruun also this is a 20 line calculator program, there's nothing to be exploited lol