## Confused about the notion of object definition in python [on hold]

I have read somewhere that “Every python object is a value having a certain type stored at a particular memory location”.The other definition of a python object is each object has a type, an identity, and a value. According to this definition, we would think of an object as a thing holding a value(a rectangular box containing integer value 36 for instance and the entire thing will be called an object, not just the value 36)which is not true when we say 36 is itself an object and there is no such thing containing 36. It does not sound good that int object 36 has an identity(id(36), type int and 36 has a value of 36. This is according to the 2nd definition so both definitions contradict? Please help

## Macbook gets confused by switching external USB keyboard

I have two different locations to use my MacBook pro and attach an external USB keyboard at both places. They are both 104keys and have identical layouts.

When I first plug in the keyboard it often (not always) stops working properly. The modifier keys will be completely incorrect and then most of the regular keys are also translated improperly.

What I have been doing is mess around with the laptop builtin keyboard a bit then back and forth for a while (tens of seconds to a minute or so) before the keyboard functionality usually gets back to normal.

I have not been able to settle on a pattern that reliably works any better than the above – which is messy and moderately unpredictable.

Has anyone run into this and come up with a better solution?

## Confused with the proof that Edmonds-Karp always monotically increases the shortest-paths

The proof for the lemma from “Introduction to Algorithms by Cormen et. al.” is not clear for me. I can’t comprehend a few things. Here is a lemma and its proof. My questions are below.

The notation $$\delta(u, v)$$ is used to denote shortest-path from $$u$$ to $$v$$.

My questions are:

Because of how we chose $$v$$, we know that the distance of vertex $$u$$ from the source $$s$$ did not decrease, i.e., $$\delta_{f’}(s, u) \geq \delta_{f}(s, u)$$

Why the shortest-path from $$s$$ to $$u$$ after the augmentation of flow $$f$$ must be greater than or equal to the distance before the augmentation ? How it is possible to have greater distance that it was ? The augmentation only removes the edge $$(u, v)$$. But, the vertex $$u$$ still in place, isn’t it must be strictly equal ?

If we had $$(u, v) \in E_f$$, then we would also have $$\delta_f(s,v) \leq \delta_f(s, u) + 1$$

This looks like ok for me to have such case. We claim that distance from $$s$$ to $$v$$ is less than or equal to the distance from $$s$$ to $$u$$ plus 1. But in the graph before the first augmentation this case must be true. It is false for less than case, but true for equal case.

How can we have $$(u, v) \notin E_f$$ and $$(u, v) \in E_{f’}$$ ? The augmentation must have increased the flow from $$v$$ to $$u$$. The Edmonds-Karp algorithm always augments flow along shortest paths, and therefore the shortest path from $$s$$ to $$u$$ in $$G_f$$ has $$(v, u)$$ as its last edge.

The edge set $$E_f$$ is before the first augmentation and $$E_{f’}$$ is after it. The first augmentation must remove the edge $$(u, v)$$ and put the reverse edge $$(v, u)$$ into the edge set $$E_{f’}$$, but not the same edge $$(u, v)$$. That is why how we can have $$(u, v)$$ in $$E_{f’}$$ ?

## I am so confused about postfix and prefix expressions and side-effects in C

I am a freshman in the computer science right now. Actually, I have been learning C and other kinds of programming since I was about first grade in high school.

I am learning about the Postfix and Prefix Expressions right now.

I am using GCC and Xcode for my personal development environment. However, in school, we use Visual Studio 2017. And the result comes out different in both compilers. So I am pretty much confused how I can understand this. I have been googling this question, but haven’t found any answers yet, so I am posting a question here. (If this post is inappropriate or already has an answer, then let me know.)

Let’s say that we have a code in C99.

int a;  int b;  a = 10; b = a++ + a++;  printf("Value of a is %d\n" , a); printf("Value of b is %d\n" , b); 

I skipped preprocessor part and main function part to save some space. Also, I do know that using those expressions to evaluate ‘b’ is not a good way.

In GCC Environment

Value of a is 12 Value of b is 21 

In Visual Studio Environment

Value of a is 12 Value of b is 20 

What I have figured out and understood is that, In GCC, ‘b’ is evaluated like this; 10 + 11 = 21 In Visual Studio, ‘b’ is evaluated like this; 10 + 10 = 22;

In GCC, I think the calculation process is done like this.

1. Got value from variable (a = 10)
2. Added 1 to the variable (a = 11)
3. Got value from variable (a = 11)
4. Added 1 to the variable (a = 12)

So, it is done 10 + 11 = 21 in this case.

However, in Visual Studio, I think the calculation process is done like this.

1. Got the value from the variable (a = 10)
2. Got the value from the variable (a = 10)
3. Added 1 to the variable (a = 11)
4. Added 1 to the variable (a = 12)

So, it is done 10 + 10 = 20 in this case.

The first question is, Am I understanding this correctly?

I have learned from the textbook that, side-effect comes after the ;(semicolon). In that case, it matches the Visual Studio case. However, It does not seem to fit in the GCC case in my opinion since the side-effect came before the semicolon.

The second question is, So, does the timing when side-effect comes vary between compilers?

Since I live in Korea, where we do not use English as native language, so I might sound little strange. I hope your understanding. And also, I do not know how compiler works, so I might say something different and wrong.

Thanks for reading this long question. Have a Nice day!

## Confused about constructing the “failure table” in Knuth-Morris-Pratt algorithm

I’m trying to learn how the “failure table” is constructed in the Knuth-Morris-Pratt algorithm since it seemed nontrivial to me that you could do it in $$O(k)$$ time (where $$k$$ is the length of the pattern, $$W$$). To be clear, we let the failure table $$T$$ be a length $$k$$ array where $$T[i]$$ is the length of the longest proper prefix of $$W$$ which is also a suffix of $$W[1]\cdots W[i]$$.

I was trying to understand it better by reading the following code:

    vector<int> T(pattern.size());     T[0] = 0;     int j;     for (int i = 1; i < pattern.size(); i++) {         j = T[i - 1];         // Find largest j s.t. T[:j+1] == T[i-j:i+1]         while (j > 0 && pattern[j] != pattern[i]) {             j = T[j - 1];         }         T[i] = (pattern[j] == pattern[i]) ? j + 1 : j;     }     return T; 

The part I’m confused about is why pattern[j] == pattern[i] is enough to guarantee that $$T[i] = j + 1$$. I was trying to prove this inductively but have had no luck. I’ve phrased the problem as follows:

Suppose $$W[1]\cdots W[T[i – 1]] = W[i – T[i – 1]]\cdots W[i – 1]$$. If $$W[i] == W[j]$$, then is it true that $$W[1]\cdots W[j] == W[i – j + 1]\cdots W[i]$$?

I can’t make any headway with this, nor can I see why it should be true. It still seems like we have to check $$W[\ell] = W[i – j + \ell]$$ for all $$\ell = 1…j$$. I can’t figure out how to use the inductive hypothesis to prove this result. Do I have to use strong induction (where we assume all prior steps are true and not just the previous step) to prove this?

## Confused with specific SQL query, AvgPrice

Please let me know if this is correct, and if not, what the correct or best way to write the SQL query would be. I am a beginner so I apologise if this is obvious to you. I believe I have to use a JOIN but unsure how.

THIS IS ONLY ASKING ABOUT QUESTION C) Get the average price of products produced by each product line. Name the average price “AvgPrice”.

  SELECT AVG(price) AS "AvgPrice"     FROM product_line GROUP BY product_line; 

## Confused on Fourier Transform. What is amplitude spectrum and phase?

I can’t understand how can I get the second formula by using the Euler formula on the first equation. How can I get ride of the summation symbol?

## How can I prevent my Good-aligned spider deity from being confused with Lolth?

I have been working on a custom campaign setting for D&D 5e for a while now, and one of the key themes of the setting is “the races aren’t what you think they are at first glance”.

The drow in particular are not the standard Forgotten Realms drow. They’re nomadic, caravan-forming, heat-averse desert dwellers. They’re charismatic with strong written, musical, and dance traditions. They’re not light-sensitive nor are they evil, but they still use poisons, albeit like modern rat-poison, not sleep poison or paralytic. They engage in peace and trade, have magical affinity, and navigate by the stars.

However, they still revere spiders strongly, and have domesticated some ground-hunting spider species for vermin control and as enormous pets, so a deity whose imagery is based around spiders makes sense for them to have. Furthermore, hunting/war, eternal vigilance, healing and magic, and defending freedom and the weak are the main themes I am working with, considering the roles spiders play in their society as protectors of food stores and wardens against disease; furthermore, they already have deities of the sun (Pelor, covering Life and Light), of trickery and the arts (including weaving and stories) (Olidammara, due to bards being common among them, and covering Trickery), and of the stars (Celestian, covering Knowledge). Rites include insect-offerings and dances while small, unattended shrines are commonplace in their homeland.

So, I ask: how would I make make the lore and imagery communicate to the PCs that this Chaotic Good spider-god is clearly distinct from Lolth, to the point where my players do not jump to the (wrong and quite detrimental) conclusion that these drow are also Lolth-worshippers, with all the Evil-aligned baggage that deity entails, upon seeing spider-themed religious images for the first time? I do wish to communicate this in-character for the sake of immersion, and also as a “backstop” for players who may not pay full attention to out-of-character cues.

I found the following content in the file: /etc/iproute2/rt_tables

255 local 254 main 253 default 0 unspec #1 inr.ruhep 126 anycast_test_1 127 anycast_test_2 

I did read some documents about rt_tables, but I still can’t understand what do the numbers mean, such as: 255,254,254,0,126,127

Do the words(in the right side) represent iptables, such as: local,main,default,unspec,anycast_test1 ... If so, where can I find these tables? I mean is there a file called local or main which would contain some routing items/rules just like a route table in router device.

## Taylor Polynomial for Log(1-t) derivation {confused}

I need some help understanding something from my textbook. In the book they are deriving a taylor polynomial approximation for log(1-t), the first thing they do is integrate log(1-t) from 0 to t.

What I don’t understand is why are we integrating in the first place?

If I wanted to find the taylor polynomial representation for this function wouldn’t I take the derivatives and construct it using the Taylor series formula?

Some help / explanation would be great