Python CARROTS?? #python #programming #coding

preview_player
Показать описание
This video explains what the exclusive or (xor) sign is in Python and how it may be confused with the power symbol. This video also explains Python's find() method.

Background Music:
Creative Commons Attribution-ShareAlike 3.0 Unported
Рекомендации по теме
Комментарии
Автор

Ill pretend to understand everything and come back later

KingKhiGaming
Автор

For whoever doesn't understand the ^:

y is 1 (dec). 1(dec) = 01(dec) = 01(bin).
2(dec) = 10(bin)
01 xor 10
First digit: 0 xor 1 returns 1
Second digit: 1 xor 0 returns 1
First digit and second digit concatenated:
11
11(bin) = 3(dec)

rubenvanderark
Автор

Coming from other languages I would assume this resolves in the following way:
x = 'b001'
y = [x.find('0')] probably ends up being [1] or something
z = len(y)^2, in C++ len(y) would return 1, and 1 ^ 2 would be 1 XOR 2, so 0b01 XOR 0b10 which is 0b11, which is 3
Thus it would print 3

But the intro said "caret is not what you think in Python", so my guess is that in Python as opposed to other languages, ^ is instead used for power, so my guess that it's 1 to the power of 2, which is still 1. So my answer is 1.

Edit: Just watched it. I've been bamboozled, it's the same as every other language, not at all different than you'd think.

kirdow
Автор

That is also called bitwise XOR operator

debpratimbose
Автор

Dude really thread.started himself in that intro

memetech-
Автор

I never knew the xor symbol is called a caret, so I just thought it's some kinda new operation you were talking abt

k_gold
Автор

Thumb up for the bad pun...even though I expected it! And I knew what this video is gonna be about! 😁

fairphoneuser
Автор

bit operator :
And: &
Or: |
Xor: ^
Not: ~

Fine_Mouche
Автор

Never knew that, interesting! May God bless.

aidennelson
Автор

"So I held a poll the other day and i realized my followers are dumb as hell" 🤣

dwidger
Автор

Ehat is even the definition of a script in this language.

alext
Автор

I use carets in math alot so this was no suprise

gimmityclark
Автор

I knew that in python ** means power but I still thought that ^ also meant power

kokeeyousef
Автор

Bcos of that corny joke, you get a sub. I want more.

snich
Автор

Now I know why I failed my exam in this topic

baumi_
Автор

I got confused on the last part when you brought up the^

threecouchpotatoes
Автор

I did not guess but actually searched for the find and caret function to get the correct answer '3'.

deepakshah
Автор

Oh I was reading in java. I forgot python uses **

hikari
Автор

Nope. A Caret was exactly what I thought.

TheSkepticSkwerl
Автор

Now we need to know why Python doesn't use ^ as an exponent.

TheOtherSteel