• 26-04-2023, 18:27:10
    #1
    Merhaba. Bir komşunun çocuğuna quiz oluştur 4 farklı ve skoru yazsın en sonra yanlış olursa da devam etmesin sıfırdan başlasın gibi bir ödev vermiş. Neyse ChatGPT ile hall edib verdim çocuğa ama kendimi gerçekten aptal hiss ettim. Kendim öğrenmek istiyorum. En etkili en iyi öğrenebileceğim bu tarz şeyleri neresidir?
  • 26-04-2023, 18:52:45
    #3
    Böyle bir quiz sistemini kendim yazmak yerine ChatGPT'ye yazdırdığım için kendimi aptal hiss ediyorum.

    print("Welcome to the Python Quiz!")
    print("Choose the correct answer from the options (a, b, c, d). You only have one attempt.")
    
    questions = [
        {
            "question": "What is the result of 3 + 4?",
            "options": {
                "a": "5",
                "b": "6",
                "c": "7",
                "d": "8"
            },
            "answer": "c"
        },
        {
            "question": "What is the value of x after the following code is executed? x = 5; x += 2;",
            "options": {
                "a": "5",
                "b": "6",
                "c": "7",
                "d": "8"
            },
            "answer": "c"
        }
    ]
    
    correct_answers = 0
    play_again = "yes"
    
    while play_again == "yes":
        for q in questions:
            print(q["question"])
            for opt in q["options"]:
                print(f"{opt}. {q['options'][opt]}")
            user_answer = input("Your answer: ")
            if user_answer == q["answer"]:
                print("Correct!")
                correct_answers += 1
            else:
                print("Incorrect. Game over.")
                play_again = input(f"You got {correct_answers} correct answers. Do you want to play again? (yes/no) ")
                break
    
    print("Thanks for playing!")