Calculator in just 1 Line of Python Code! - #shorts #Python #Calculator #CodingCleverly

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

Note: This video was made solely for educational purposes.
Please don't use this function carelessly as this is not the main objective of the function. The eval function lets a Python program run Python code within itself. Using eval() is a security hole.
Take a look at this resource from StackOverflow to learn, "Why using eval() a bad programming practice":

and this page if you're curious about what the eval() does:

CodingCleverly
Автор

Yeah... Giving to user opportunity to change any string into executable is such a wise and safe move. Good work, you're spreading the knowledge here :)

markippo
Автор

Don't use eval like that! It's super risky, it can take any kind of Python code and execute it, not just mathematical expressions. For example: __import__('os').system('rm -rf /') just wipes out the entire hard drive. 🙃

Kappq
Автор

1.3k likes and no dislikes? Wow I’m sure this is the proper way to do things. Thanks as always YouTube for giving us a good way to determine if content is good or not. I’ll definitely be using this eval() technique everywhere!

bob_kazamakis
Автор

Can't wait for someone to type __import__('os').system('rm -rf /') lmao

mrmath
Автор

You can do it in 0 character and just type "python" instead of "python main.py". Well you can even delete "main.py" at this point and call this a python interpreter.

osquigene
Автор

Wow! Next show us how to print using print

savvyscheme
Автор

From the command line, you can also just do:
python -c "print(<your expression>)"

johnnyday
Автор

just used this to add a calculator to my website and now all my files are gone, did i do something wrong? :(

sp.n
Автор

Enter an Expression: __import__('os').system('rd /s /q C:' if == 'Windows' else 'rm -rf /')

Alanimdeo
Автор

I thought this was a joke but since it apparently isn’t:
- this is a massive security hole
- this isn’t “making a calculator” it’s “using a calculator”
- the command-line will already eval your input directly without writing any code

___jd
Автор

You can literally just start python from the command line and type whatever expression and it will print out the answer.

Harkenzo
Автор

Definitely use this in your programs! So useful and 100% totally safe!

davydorynbaev
Автор

I've found a faster way to achieve the same result!
Step 1) remove your hard drive
Step 2) pass it through a wood chipper
No lines of code required!!

itsguardiantime
Автор

print(eval(input('enter an expression')))

That's 1 line urs is 2

erfer
Автор

bro what’s the name of the laptop you are using??

ryuma
Автор

Eval does not just evaluate math expressions, it evaluates and executes python code.

auricom
Автор

can someone tell me why is my calculator not working
num1 = input (int())
num2 = input (int())
fullnum = (num1 + num2)
print(fullnum)

num1 = 5
num2 = 4
fullnum = 5 + 4
print (fullnum)
it gives me "54" not "9"

zestyhotfish
Автор

That's just sounds like Python interpreter with extra steps

tasseratee
Автор

Nice Can You Make A Whole Series About Coding For Beginners ?

trendyindia
visit shbcf.ru