0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Python3エンジニア基礎試験_模擬試験の復習⑤

Posted at

タプル、集合、辞書

tuple.py
以下のプログラムを実行した際と等価の記述を選択肢の中から選びなさい
t = 123,345,'test'
# t = (123,345,'test')

● 解説
タプル定義の問題です。
通常、タプルの定義は () で囲む必要がありますが、省略も可能です。
この場合、問題文が省略されている形で書かれています。

ex.py
条件についての説明で誤っているものを選択肢から選びなさい
# 比較はブール演算のand及びorによって組み合わせることができ、
# また比較の結論はnotにより否定ができる。これらの優先順位は比較演算子よりも高い。

● 解説
優先順位は、比較演算子よりも and / or / not が低いです。
そのため「これらの優先順位は比較演算子よりも高い」という箇所が誤りです。

dict.py
member = {1: 'Noro', 2: 'Nakao', 3: 'Miyaoka'}
member[4] = 'Kimura'
del member[3]
print(list(member.keys()))
# [1, 2, 4]

● 解説
辞書機能の問題です。del で member から 3 の key を削除しています。
そして、最後に key だけを出力しているので、1, 2, 4となります。

dict.py
dic = {'Noro': 1, 'Nakao': 2, 'Miyaoka': 3}
dic['Miyaoka'] += 1
print(dic)
# {'Noro': 1, 'Nakao': 2, 'Miyaoka': 4}

● 解説
辞書型データの問題です。key である Miyaoka に 1 を加算していますが、
ここで加算されるのは value の 3 です。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?