Do You Actually Know Python??
This short video explains the exclusive or (xor) operator and how it may be confusing with the power operator.
Background Music:
Gentle Lo-Fi Vlog Background Music | Cookies by Alex-Productions | onsound.eu/
Music promoted by www.free-stock-music.com
Creative Commons Attribution 3.0 Unported License
creativecommons.org/licenses/...
Пікірлер: 123
This is why I code every day and still don't call myself a programmer.
@murderspree
Жыл бұрын
what type of stuff do you code? i have been programming since 2016 and i cant find anything to code anymore..
@Mr.Fantomblox
Жыл бұрын
@@murderspree there is always something new on leetcode
@ygx6
Жыл бұрын
@@murderspree personally I just do freelancing projects
@Arjun----
Жыл бұрын
@@murderspree neural networks/ML/Data science, build apps in java, game design, and like people mentioned, leetcode and freelancing
@bdav0
Жыл бұрын
@@murderspree learn a new language, hone your skills, etc - there’s always something to do I’ve been writing code since 2012, but really programming since like 2020
Hahaha You can't fool me ^ is a bitwise XOR operator, not an exponent.
“how well do you actually know python” sir, i use C++
@IonicMC
6 ай бұрын
Same
I knew what it was, i just had no idea what it does
@chuchichastli3809
Жыл бұрын
Its calculating what you just did... That is not code😅
@samueljehanno
Жыл бұрын
@@chuchichastli3809 you didn't get it
I was totally thinking mathwise
Started with C, so i know the Bitwise Operators, can't fool me 😎
Fun fact: the boolean equivalent of a bitwise XOR operator is the inequality operator != . This can be used, for example, to check whether two numbers are both negative (same sign), both positive (same sign), or one is positive while the other is negative (different signs): if (a # one is positive and one is negative (different signs) else: # both positive/both negative (same sign) This is also how the bitwise operation works on individual bits, which can only be 1 (True) or 0 (False), so if they're the same, you get 0 (False) as the output, else you get 1 (True). It follows that if ^ is for bitwise XOR, and != is the boolean equivalent, then == is the boolean opposite, which means ~(a ^ b) is the bitwise opposite (only selects the bits that are equivalent): ~(0b00000010 ^ 0b00000100) → ~(0b00000110) → 0b11111001 a&b - selects bits that are set in both a and b ~(a&b) - selects bits that are NOT set in a or NOT set in b or NOT set in both a and b a|b - selects bits that are set in a or set in b or set in both a and b ~(a|b) - selects bits that are NOT set in both a and b a^b - selects bits that are NOT equal in a and b, i.e. set in a or set in b, but NOT set in both a and b ~(a^b) - selects bits that are equal in a and b, i.e. NOT set in a and NOT set in b, or set in both a and b The only potential problem with ~ is the fact that it will flip hidden leading 0s to leading 1s, which results in a negative value, so beware!
I LEARNED SOMETHING NEW!
Dude that's crazy I have been studying python for a short while I plan on making it my career I actually did this one correctly
even though i know the answer to this my math brain always tells me that it is an exponent
Thank you for the useful information
Im lucky I watched a video on that just last week 😎
Damn most people are still misunderstanding ^ is exponential
@s1l3nttt
Жыл бұрын
No shit python is dumb as fuck, next they'll change the + signal to mean a hashmap
How I managed to forget the bitwise XOR operand? I thought since this is a quiz question about Python, there must be something about "pythoning" features. It ends up about simple logic in any programming language
I believe XOR is pronounced "ex or" as in 'exclusive or'.
@b001
Жыл бұрын
I think you’re right, but my brain has always pronounced it “zor” and I can definitely see how that may confuse people
@hashirkz
Жыл бұрын
@@b001huh ive also always called xor zor lol
@tzabarpho.
Жыл бұрын
@@hashirkz lol I call it kcsor
@philstanton8912
Жыл бұрын
yeah it’s technically “ex or” or thats i’ve heard it called my entire life. See were zor comes from tho
@moranii1843
Жыл бұрын
Nah
Whoops. I knew it was a bitwise, but thought it was OR not XOR
Super
Bro aint foolin no one
c++ learners on fire 🔥😅
i didn't know about this and thought it will return an error
^ and ** are confusing)
XORing any value by itself is 0 btw so it’s not really “in our case” like he said it’s just always like that
I confused ^ with / and still got it right
Somehow even though I knew that the Python operator for raising a number by a power is double star (**). I didn't notice the mistake until it was shown.
mistook that for AND operation
Woow, well this was something that I didn’t know about
I've been seeing these bitwise operators pop up and while I understand the general concept that these compare the bits, I suppose I'm just not understanding why we would want to do this. Can you explain the application for these bitwise operators?
@rksmehul
Жыл бұрын
Not that useful. One use is bitmasking
@nyverinorlyth9555
Жыл бұрын
I write mostly rust and sometimes C and ASM code, bitwise operations are very useful when optimizing some operations, I can see why it may not be as common to use in python.
@undercover4874
Жыл бұрын
Ever wondered for any case we need a an array of bool type just to store 1 and 0. a single variable is 4 bytes meaning '32' bits only one of them.is used. Why not we use all of the 32 bits when we just want to store a single 1 and 0. well thats when we need bitwise operators to manipulate individual bits and turn them on or off get them its more space efficient this way.
@benp2291
Жыл бұрын
Bitwise xor is useful for a quick encryption, say x is plain text and k is our key. If I showed you x^k, you wouldn’t be able to know what x was - there’s no way to undo a bitwise xor unless you knew what k was, because (x^k)^k=x
XOR
Xor
btw the square of (x-1) would be: (x-1)**2
Hmmm. Seems I need to take out Python for dinner more often.
@greenfire2783
Жыл бұрын
Maybe put a guard on it's mouth so it doesn't bite you
Not a python dev, got it right. It's more like how well you know C/C++
If we’re gonna be 🤓 then you should also know it’s not called the power operator but the exponent(iation) operator
Python uses ** as a power operator
any way to have it print the binary results; so you can read them? For example print 22 in binary
** is the exponent operator
when would you need this operator for example?
@floskater99
Жыл бұрын
Whenever you want to do Bitwise XOR. Probably never. It‘s more commonly used in C, noone uses it in Python.
F.... I did indeed
Me who just did (a-b)^2 from my maths class and made x=1 :d
I said 2..but ive only been learning python for 4 dsys now...
Hahaha you can fool me kept thinking that ^ was an exponent not a bitwise XOR operator
which font are you using?
People dont confuse ^ with ^ ^ . ^ is XOR and ^ ^ is power
Which coding engine used in this video
A number xor itself will be 0 always. It's basic CS concept
What editor is this?
Ya Xor exists, knew this one
which font u using?
As an electronic engineer, this is not ZOR. Don't make it a thing
The more I watch your shorts, the more I am thankful I learnt c# and not python
@sustrackpointus8613
Жыл бұрын
Wdym, u dont know there is xor operator in c# or u dont want to deal with community of people that just got into coding?
Name of the app And I want the name of the python app to install for PC(window 7)
What do you use ^ for then?
@Nemo42239
Жыл бұрын
@@qwerty_qwerty ok what do you use the xor operator for?
Output: 0. Anything xored to it self is zero
I got it right but with the wrong formula
Wouldn't have been fooled if this was any C like language, but Python likes to just do random magic to "make a programmers life easier" and randomly decides not to at other spots. Python is the only language where I can totally see this operator being used as a power operator.
That's every programming language. Also it's X Or not ZOR
WTF ^ is literally or how- well anyways at least I know how to xor now
The ZOR operator?? 😭😭😭
@Rainmakeroffire
Жыл бұрын
Have no fear, XORRO is here
Ya got me :(
Python is such a bad language. E. g. in Rust ^ is an exponential as it should be.
Im stupid, got myself to think it was (2x-1)^2 and then 5 is 101 ^ 10 = 101 ... there was no 5 and i got over confused 😂
I knew that
In java it is also same...
I’m still a little confused why does it equal 0 instead of two since it comes first in this case?
@chinjoka7418
Жыл бұрын
XOR operator works bite operation. 1xor1 and 0xor0 means 0 1xor0 and 0xor1 means 1 So both 2^2 bitewise 10^10 = 00
I knew it wasn’t exponent but i didn’t know what ^ did so half way ig? 😅
Looked at that, but I know that to get an exponent in python its ** not ^
but why is it like this ? why do I have to remember myself each time I get this "error" that I have to change ^ to **
@sustrackpointus8613
Жыл бұрын
In most languages ^ is already used as xor, so actually u dont need to remember this specifically, it would be more confusing if they replaced ^ (xor) with any other operator
Who taught you it was zor? It’s x-or.
Thank God I use JS
import math math.pow
Its called exclusive or, thus pronounced ex-or. Not zor
alguem traduz ai pfv
**
I said error 😢
D
In c# its ^^ instead of ^
@tomchapman128
Жыл бұрын
I'm pretty sure its still ^
"if you're like me" oh, so you didn't get it at the first try. i did.
Obviously I don't know Python well. The ^ character should be for raising to a power, not XOR.
@tildejustin
Жыл бұрын
**
@Ali-oo4wi
Жыл бұрын
you are not right my friend, here how we do it... 3**2 = 9 ( 3 power of 2 = 9 )
@johnleuenhagen9068
Жыл бұрын
^ is xor in almost every programming language.
I think the answer is D
ez
zore
Why does this Operator exist i dont understand
I am appalled by your pronounciation of xor
What?
Why c code always return 0?
@sirmonke8946
Жыл бұрын
Back when C was created, I'm pretty errors were not handled by error messages, but instead by returning numbers that will be displayed. A return of 0 means that the program ran successfully. I don't think you are required to return 0 though, at least not anymore, but it is still the convention. Correct me if I'm wrong.
@ownedbyptr
10 ай бұрын
mov eax, 0 int 0x80 ; if u won't set exit code in assembly, ;it will segfault
Is this why none of my code has worked for the last 10 years??????????? What the hell is exponent then!?
@rz2374
Жыл бұрын
exponents are **
Gotta do (x-1)**2
but is this knowledge any useful tho
its 0 thanks to zor(XOR)
**