Skip to content

Instantly share code, notes, and snippets.

@hoadh
Created March 30, 2024 03:39
Show Gist options
  • Save hoadh/d6cfd63871e211f647ebc4f8d9c690b1 to your computer and use it in GitHub Desktop.
Save hoadh/d6cfd63871e211f647ebc4f8d9c690b1 to your computer and use it in GitHub Desktop.
# Khởi tạo biến
score = 0
current_question = 1
# Vòng lặp cho game
while current_question <= 3:
# Câu hỏi 1
if current_question == 1:
answer = input("Câu 1: Python được phát hành vào năm nào? A. 1991, B. 1989, C. 2000, D. 1995: ")
if answer.upper() == "A":
print("Đúng!")
score += 1
else:
print("Sai!")
# Câu hỏi 2
elif current_question == 2:
answer = input("Câu 2: Ai là người tạo ra Python? A. Guido van Rossum, B. Dennis Ritchie, C. James Gosling, D. Bjarne Stroustrup: ")
if answer.upper() == "A":
print("Đúng!")
score += 1
else:
print("Sai!")
# Câu hỏi 3
elif current_question == 3:
answer = input("Câu 3: Câu lệnh nào dùng để hiển thị dữ liệu ra màn hình trong Python? A. print(), B. cout<<, C. System.out.println(), D. echo: ")
if answer.upper() == "A":
print("Đúng!")
score += 1
else:
print("Sai!")
# Cập nhật câu hỏi
current_question += 1
# Hiển thị điểm số
print(f"Bạn đã trả lời đúng {score} trên 3 câu!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment