Python 3エンジニア認定基礎試験~模擬試験④~

1. 
次のコードを実行した場合、出力は何ですか?

from collections import deque
dq = deque(maxlen=3)
dq.append(1)
dq.append(2)
dq.extend([3, 4])
print(dq)

2. 
リストitems = [1, 2, 3, 4, 5]に6を追加する正しい方法はどれでしょうか?

3. 
次のコードの出力結果は何ですか?

x = 10
y = 3
z = 4
result = (x + y * z) % (x - y)
print(result)

4. 
次のコードを実行したときの出力結果は何でしょうか?

concat = lambda x, y="default": x + y
print(concat("Hello, "))

5. 
次のコードを実行した場合、出力は何ですか?

from collections import deque
dq = deque(["a", "b", "c"])
dq.appendleft("z")
print(dq)

6. 
次の出力を得るためには、どのようなコードを入力すべきですか?

Number: 7.0

7. 
次のコードの実行結果を選んでください。

class MyClass:
def __init__(self, values):
self.values = values

obj = MyClass([1, 2, 3])
obj.values[0] = 10
print(obj.values)

8. 
リストvalues = [5, 3, 8, 1, 9]を昇順にソートするにはどうすればよいでしょうか?

9. 
次のコードの出力結果は何ですか?

x = 10
y = 3
print(x + y)

10. 
次のコードの出力は何でしょうか?

data = [10, 20, 30, 40, 50]
data[1:4] = [15, 25]
print(data)

11. 
次のコードの実行結果を選んでください。

class A:
pass

class B(A):
pass

class C:
pass

print(issubclass(B, (A, C)))

12. 
次のコードを実行した場合、出力は何ですか?

from collections import deque
dq = deque([1, 2, 3])
x = dq.popleft()
y = dq.pop()
print(dq)

13. 
次のコードの出力は何でしょうか?

data = [0, 1, 2, 3, 4]
data[1:3] = [8, 9]
print(data)

14. 
次のコードを実行したときの出力結果は何でしょうか?

add = lambda x, y=10: x + y
print(add(5))

15. 
次のコードの実行結果として正しいものを選んでください。

class A:
pass

class B(A):
pass

print(issubclass(A, B))

16. 
次のコードを実行した場合、出力は何ですか?

from collections import deque
dq = deque([1, 2, 3])
dq.clear()
print(dq)

17. 
次のコードの実行結果を選んでください。

class MyClass:
def __init__(self, name):
self.name = name

obj = MyClass("Bob")
del obj.name
print(obj.name)

18. 
次のコードの出力結果は何ですか?

x = 6
y = 7
z = 2
result = x ** z // y + x % z
print(result)

19. 
次のコードを実行したときの出力結果は何でしょうか?

sort_last = lambda x: sorted(x, key=lambda y: y[-1])
print(sort_last(["apple", "banana", "cherry"]))

20. 
次のコードの実行結果を選んでください。

class MyClass:
def __init__(self, value):
self.value = value

obj = MyClass(5)
print(obj.value)
obj.value = 10
print(obj.value)

21. 
次の出力を得るためには、どのようなコードを入力すべきですか?

Number: 1.23e+02

22. 
次の出力を得るためには、どのようなコードを入力すべきですか?

Result: 3.1

23. 
次のコードの実行結果を選んでください。

class A:
pass

class B(A):
pass

class C(B):
pass

obj = C()
print(isinstance(obj, A))
print(type(obj) == A)

24. 
dequeで要素を先頭に追加するメソッドはどれですか?

25. 
次のコードの出力結果は何ですか?

a = 8
b = 3
c = 5
result = a // b + b * c - a % c
print(result)

26. 
次の出力を得るためには、どのようなコードを入力すべきですか?

Aligned: text

27. 
次のコードの実行結果を選んでください。

class MyClass:
def __init__(self, value):
self.value = value

def reset(self):
self.value = 0

obj = MyClass(10)
obj.reset()
print(obj.value)

28. 
次のコードの出力結果は何ですか?

x = 17
y = 5
print(x % y)

29. 
次のコードについて、正しい説明はどれですか?

filter_even = lambda x: x % 2 == 0
print(filter_even(5))

30. 
次のコードの出力として正しいものはどれですか?

increment = lambda x: x + 1
print(increment(10))

31. 
次のコードの実行結果を選んでください。

class A:
pass

class B(A):
pass

obj = B()
print(type(obj) == A)

32. 
次のコードの出力結果は何ですか?

print("The result is {0:.1f}".format(10 / 3))

33. 
次のコードの実行結果を選んでください。

class A:
pass

class B(A):
pass

class C(B):
pass

print(issubclass(C, A))
print(issubclass(C, object))

34. 
次の出力を得るためには、どのようなコードを入力すべきですか?

Hexadecimal: ff

35. 
次のコードを実行した場合、出力は何ですか?

from collections import deque
dq = deque([1, 2, 3])
dq.append(4)
print(dq)

36. 
次のコードを実行した場合、出力は何ですか?

from collections import deque
dq = deque([1, 2, 3, 4])
dq.extendleft([5, 6])
print(dq)

37. 
次のコードについて、インスタンス生成時に渡される引数の用途として正しいものを選んでください。

class MyClass:
def __init__(self, name, age):
self.name = name
self.age = age

38. 
次のコードの実行結果を選んでください。

class MyClass:
def __init__(self, value):
self.value = value

obj1 = MyClass(10)
obj2 = obj1
obj2.value = 20
print(obj1.value)

39. 
次のコードを実行した場合、出力は何ですか?

from collections import deque
dq = deque([1, 2, 3])
dq.pop()
print(dq)

40. 
dequeのextendleftメソッドの動作として正しい説明はどれですか?

コメントを残すにはログインしてください。