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

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

import math
print(math.pow(2, 3))

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

queue = [10, 20, 30]
queue.append(queue.pop(0) + queue[-1])
queue.append(queue.pop(0) * 2)
print(queue)

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

queue = [5, 10, 15]
for _ in range(2):
queue.append(queue.pop(0) * 3)
print(queue)

4. 
datetimeモジュールで日時の差を計算するために使用されるクラスとして正しいものを選んでください。

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

score = 75
if score >= 90:
print("A")
elif score >= 80:
print("B")
elif score >= 70:
print("C")
else:
print("D")

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

from random import randint
print(randint.__name__)

7. 
Pythonのモジュールに関する次の記述のうち、__name__属性の役割として正しいものを選んでください。

8. 
次のコードを実行した場合の出力として正しいものを選んでください。

from datetime import datetime

date = datetime(2024, 2, 29)
days_to_add = 365
new_date = date.replace(year=date.year + 1) + timedelta(days=days_to_add - 1)
print(new_date.strftime("%Y-%m-%d"))

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

x = -10
if x > 0:
print("正の数")
elif x < 0:
print("負の数")
else:
print("ゼロ")

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

import time
start = time.time()
time.sleep(2)
end = time.time()
print(end - start)

11. 
次のコードを実行した後、queueの内容は何でしょうか?

queue = [1, 2, 3]
queue.pop(0)
queue.append(4)
queue.pop(0)
queue.append(5)
queue.pop(0)

12. 
次の記述のうち、Pythonのimportに関して正しいものを選んでください。

13. 
Pythonのstatisticsモジュールで、平均値を計算するための関数として正しいものを選んでください。

14. 
キューとして機能するリストqueueに要素10を追加するには、次のどのコードを使用すべきでしょうか?

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

queue = [10, 20, 30, 40]
queue.pop(0)
queue.append(queue.pop(0))
queue.append(50)
queue.pop(0)
print(queue)

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

import sys
print(sys.__file__)

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

x = 7
y = 4
if x > 5:
if y < 5:
print("x > 5 かつ y < 5")
else:
print("x > 5 かつ y >= 5")
else:
print("x <= 5")

18. 
次のコードを実行した場合の出力として正しいものを選んでください。

import statistics
data = [10, 20, 30, 40, 50]
mean = statistics.mean(data)
stdev = statistics.stdev(data)
print(round(mean + stdev, 2))

19. 
Pythonにおいて、標準ライブラリモジュールmathを使用するための適切なコードを選んでください。

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

import random
print(random.__name__)

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

import math
print(math.__cached__)

22. 
次のコードを実行した場合の出力として正しいものを選んでください。

import math
result = math.log10(100) + math.factorial(3)
print(result)

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

queue = []
for i in range(3):
queue.append(i * 2)
queue.pop(0)
queue.append(queue.pop(0) + 5)
print(queue)

24. 
次のコードを実行した場合の出力として正しいものを選んでください。

from datetime import datetime, timedelta

current = datetime(2024, 11, 17, 15, 0)
adjusted = current - timedelta(hours=5, minutes=30)
print(adjusted.strftime("%Y-%m-%d %H:%M"))

25. 
変数tempが20以下なら「寒いです」と表示し、20より大きく30未満なら「快適です」と表示するコードはどれでしょうか?

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

queue = [5, 15, 25]
queue.append(queue.pop(0) * queue.pop(0))
queue.append(queue.pop(0) - 10)
print(queue)

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

import math
print(hasattr(math, "__file__"))

28. 
キューqueueが空であるかどうかを判定するためのコードはどれでしょうか?

29. 
変数xが正の数であるか、または偶数である場合に「条件を満たします」と表示するコードはどれでしょうか?

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

queue = []
for i in range(3):
queue.append(i + 1)
queue.append(queue.pop(0) + 5)
print(queue)

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

temperature = 22
if temperature > 30:
print("暑いです")
elif temperature >= 20:
print("快適です")
else:
print("寒いです")

32. 
次のコードでtimeモジュールを別名でインポートした場合、関数sleepにアクセスする正しい方法を選んでください。

import time as tm

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

a = 3
b = 8
if a 10:
print("条件1が成立")
elif a 5:
print("条件2が成立")
else:
print("どちらも成立しません")

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

x = 7
if x > 5:
if x < 10:
print("5より大きく10未満です")
else:
print("10以上です")
else:
print("5以下です")

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

import os
print(os.__package__)

36. 
次のコードを実行した後のstackの内容は何でしょうか?

stack = []
for i in range(3):
stack.append(i)
stack.append(stack.pop() + stack.pop())
stack.append(stack.pop() + stack.pop())

37. 
変数scoreが90以上の場合に「A」と表示し、80以上90未満の場合に「B」と表示するコードはどれでしょうか?

38. 
次のコードを実行した場合の出力として正しいものを選んでください。

from datetime import datetime, timedelta

now = datetime(2024, 11, 17)
next_week = now + timedelta(weeks=1)
print(next_week.strftime("%A"))

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

import os
print(hasattr(os, "__doc__"))

40. 
次のコードを実行した場合の出力として正しいものを選んでください。

from datetime import datetime
current = datetime(2024, 11, 17, 12, 30)
print(current.strftime("%I:%M %p"))

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