Here are the answers. So, for the first question,
we had 12 modulo three and 12 is equal to
three times four. So, that means, if we divide
12 by three we get four with no remainder. So,
that means, the result of 12 modulo three is
zero. For the second question, we could solve this by
figuring out what ord of a is. But we don't
actually need to. We know that the value of ord
for 'a' is always going to be the same every
time we do it. So this is saying, the same value
modular the same value, the result is always going to
be zero. Because anything is divisible by itself with no remainder.
So that answer's also zero. For part C, well now
we've added three. In order to know what the result is
here, we've got to know whether ord of 'z' is greater
than or less than three. As long as ord of z
is greater than three, well that would mean ord of
z plus three modulo ord of z must be three,
because the remainder will be what we added to ord
of z, since ord of z by itself is always divisible
by ord of z. And we do know that ord
of z is greater than threeSo that means the result will
be 3, so let's try that last one in the
Python interpreter. We're going to print the value of ord of z,
plus three, modulo ord of z, and when we run that, we see the result is three,
and I want to point out that the parentheses
here are actually important, if we didn't have them
We tried the order z, plus three order z,
then we get the result 125. And the reason
for that is, the grouping here is going to
group three mod ord z and add that towards ord z,
so it's a different value, and the reason we get 125 is the value
of ord z by it's self. Is 122. So it's 122, which is ord
of z, plus three mod ord of z, which is three mod 122, which is
three, which is why we got 125 when we evaluated this without the parentheses.
それでは答えです
1つ目の数式は12%3でした
3かける4は12ですから
12割る3は4で余りはありません
12%3の結果はゼロです
2つ目の問題はord(‘a’)の値を決めることなく
解くことができます
実際に必要ありません aのordの値が
毎回同じになることは分かっています
ですからこれは同じ値%同じ値と言えます
結果は常にゼロになります
なぜなら同じものを同じもので割ったら
余りがないからです
ですから答えもゼロです
問題(c)は3を加えました
結果がどんなものか知るために
zのordが3より小さいのか大きいのかを
知る必要があります
ord(‘z’)が3より大きい場合に限り
(ord(‘z’)+3)%ord(‘z’)は
3になるはずです
なぜならord(‘z’)はord(‘z’)で常に割り切れるので
余りはord(‘z’)に加えたものになるからです
ord(‘z’)が3より大きいことが分かっています
つまり結果が3になるということです
Pythonインタプリタで最後の問題を試してみましょう
(ord(‘z’)+3)%ord(‘z’)の値を出します
実行すると結果が3になることが確認できます
ここにある丸括弧は重要なものなので
これも書く必要があります
丸括弧がないまま(ord(‘z’)+3)を試すと
結果は125になります そうなる理由は
このグループ化が3モジュロまたはzで分類され
それに対して加えられるからです
ですから異なる値になります
125になった理由はord(‘z’)の値は
それ自体で122です
(ord(‘z’)+3)です これが3モジュロ122になります
これが丸括弧なしで計算すると125になる理由です