0
0

More than 1 year has passed since last update.

Python3エンジニア認定基礎模試試験5回目 -間違えた問題-

Posted at

獲得点数 925/1000点

正答率: 92.5 % ( 37問 / 40問 正解 )

問題文のプログラムを実行した場合の出力結果を選びなさい
print("出力結果:")
try:
  raise Exception("開始前","Exception発生")
  print("開始")
except IOError as msg:
  print("IOError発生:",msg.args[0])
except Exception as msg:
  print("予期せぬ問題発生:",msg.args[1])
else:
  print("Else表示")

A,出力結果:予期せぬ問題発生: Exception発生

1 行目はそのまま出力されます。
次に 3 行目の raise で強制的に Exception エラーを発生させています。
そうすると 4 行目は通らず 7 行目の expect で Exception を拾い、
Exception は msg に読み替えられています。8 行目で msg が出力されています。

問題文のプログラムを実行した場合の出力結果を選びなさい
class Sample:

  c_list = []

  def add_c_list(self,data):
    self.c_list.append(data)

print("出力結果:", end=" ")
sample1 = Sample()
sample1.add_c_list("データ1") # c_list = ["データ1"]

sample2 = Sample()
sample2.add_c_list("データ2") # c_list = ["データ1","データ2"]

for item_data in sample1.c_list:
  print(item_data, end=" ")

A,出力結果: データ1 データ2
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