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

1. 
次のうち、collections.dequeについて正しい説明はどれですか?

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

language = "Python"
version = 3
print("I am learning {0} {1}.".format(language, version))

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

class MyClass:
def __init__(self):
self.count = 0

def increment(self):
self.count += 1

obj = MyClass()
obj.increment()
obj.increment()
print(obj.count)

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

a = 7
b = 2
print(a / b * b)

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

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

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

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

class A:
pass

class B(A):
pass

class C(A):
pass

obj = B()
print(isinstance(obj, C))

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

Number: 7.0

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

class A:
pass

class B(A):
pass

class C(B):
pass

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

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

Aligned: text

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

Result: 3.1

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

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

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

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

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

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

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

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

subtract = lambda x, y=5: x - y
print(subtract(10))

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

16. 
次のコードの説明として正しいものはどれですか?

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

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

power = lambda x, y: x ** y
print(power(2, 3))

18. 
次のコードについて、正しい説明を選んでください。

class A:
pass

class B(A):
pass

obj = A()
print(isinstance(obj, B))

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

nums = [1, 2, 3, 4, 5]
nums = [x * 2 for x in nums if x % 2 == 1]
print(nums)

20. 
次のコードについて、正しい出力を選んでください。

class MyClass:
pass

obj = MyClass()
print(isinstance(obj, MyClass))

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

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

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

x = 9
y = 4
result = x % y + (x // y) * y
print(result)

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

square = lambda x: x ** 2
print(square(4))

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

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

obj = MyClass([1, 2, 3])
obj.items.append(4)
print(obj.items)

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

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

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

x = 7
y = 2
print(x * y)

27. 
次のコードの出力は何ですか?

values = [1, 2, 3]
values.extend([4, 5, 6])
print(values)

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

a = 20
b = 4
result = a // b + a % (b + 1) * a / b
print(result)

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

square_diff = lambda x, y: (x - y) ** 2
print(square_diff(7, 5))

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

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

31. 
次のコードで、変数x = 10を埋め込んで「Value: 10」と出力するための正しい記述はどれですか?

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

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

33. 
次のコードについて、正しい出力を選んでください。

class Parent:
pass

class Child(Parent):
pass

obj = Child()
print(isinstance(obj, Parent))

34. 
次のコードについて、正しい実行結果を選んでください。

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

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

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

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

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

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

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

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

x = 15
y = 2
z = 3
result = x / y * z + z // y - x % z
print(result)

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

class Base:
pass

class Derived(Base):
pass

obj = Derived()
print(isinstance(obj, Derived))
print(isinstance(obj, Base))

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

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

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