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

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

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

price = 19.99
print("The price is ${:.2f}".format(price))

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

a = 14
b = 5
result = (a * b) % (b - a // b)
print(result)

4. 
Pythonで文字列の書式指定に使用するメソッドとして正しいものはどれですか?

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

multiply = lambda x, y: x * y
print(multiply(3, 4))

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

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

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

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

Name: John, Age: 25

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

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

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

calculate = lambda x, y: x * y if x > y else x + y
print(calculate(3, 5))

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

class Parent:
pass

class Child(Parent):
pass

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

11. 
次のコードについて、インスタンスメソッドの正しい説明を選んでください。

class MyClass:
def greet(self):
return "Hello!"

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

Temperature: 23.5°C

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

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

14. 
次のコードについて、issubclass関数の出力として正しいものを選んでください。

class Parent:
pass

class Child(Parent):
pass

print(issubclass(Child, Parent))

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

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

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

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

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

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

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

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

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

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

obj1 = MyClass(10)
obj2 = MyClass(20)
print(obj1.x + obj2.x)

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

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

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

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

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

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

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

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

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

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

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

class A:
pass

class B(A):
pass

class C(B):
pass

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

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

class MyClass:
pass

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

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

fruits = ['apple', 'banana', 'cherry']
print(fruits[-2])

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

x = 8
y = 3
print(x / y)

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

class Base:
pass

class Derived(Base):
pass

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

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

mod = lambda x, y: x % y
print(mod(10, 3))

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

class A:
pass

class B(A):
pass

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

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

a = 2
b = 4
print(a ** b)

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

triple_map = lambda x: list(map(lambda y: y * 3, x))
print(triple_map([1, 2, 3]))

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

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

def reset(self):
self.value = 0

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

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

name = "Alice"
print("Hello, {}!".format(name))

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

nums = [1, 2, 3, 4, 5, 6]
nums[1:5:2] = [7, 8]
print(nums)

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

Number: 7.0

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

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

39. 
次のコードの出力として適切なのはどれでしょうか?

numbers = [1, 2, 3, 4, 5]
print(numbers[1:4])

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

numbers = [1, 2, 3, 4, 5]
print(numbers[::-1])

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