Quize_creator
"Empower Your Learning Journey: Dive into Quiz Creation with Python ???"

Quize_creator

you can check full code here????????

Shivam Malviya

def select(val1, val2, op1, op2, i):
    print("Enter 1 to perform addition")
    print("Enter 2 to perform subtraction")
    print("Enter 3 to perform multiplication")
    print("Enter 4 to perform division")
    choice = int(input("Write your choice: "))

    if choice == 1:
        print("Enter two numbers for addition")
        val1 = int(input("val1: "))
        val2 = int(input("val2: "))
        print("Enter options here")
        op1 = int(input("op1: "))
        op2 = int(input("op2: "))
        print()
        print(f"Question no.{i}")
        print(f"What is the addition of {val1} and {val2}")
        print(f"Option1: {op1}\nOption2: {op2}")
        answer = val1 + val2
    elif choice == 2:
        print("Enter two numbers for subtraction")
        val1 = int(input("val1: "))
        val2 = int(input("val2: "))
        print("Enter options here")
        op1 = int(input("op1: "))
        op2 = int(input("op2: "))
        print()
        print(f"Question no.{i}")
        print(f"What is the subtraction of {val1} and {val2}")
        print(f"Option1: {op1}\nOption2: {op2}")
        answer = val1 - val2
    elif choice == 3:
        print("Enter two numbers for multiplication")
        val1 = int(input("val1: "))
        val2 = int(input("val2: "))
        print("Enter options here")
        op1 = int(input("op1: "))
        op2 = int(input("op2: "))
        print()
        print(f"Question no.{i}")
        print(f"What is the multiplication of {val1} and {val2}")
        print(f"Option1: {op1}\nOption2: {op2}")
        answer = val1 * val2
    elif choice == 4:
        print("Enter two numbers for division")
        val1 = int(input("val1: "))
        val2 = int(input("val2: "))
        print("Enter options here")
        op1 = int(input("op1: "))
        op2 = int(input("op2: "))
        print()
        print(f"Question no.{i}")
        print(f"What is the division of {val1} and {val2}")
        print(f"Option1: {op1}\nOption2: {op2}")
        answer = val1 / val2
    else:
        print("Choose the correct operation")
        return 0

    user_answer = int(input("Enter your answer: "))
    if user_answer == answer:
        print("Congratulations, your answer is correct")
    else:
        print("Wrong answer")
        print(f"Correct answer is: {answer}\n")

    if answer == op1:
        return op1
    elif answer == op2:
        return op2
    else:
        return 0

def main():
    qn = int(input("How many questions do you want to create?: "))
    for i in range(1, qn + 1):
        answer = select(0, 0, 0, 0, i)

    print("_END_")
    s = int(input("If you want to create more questions, press 22: "))
    if s == 22:
        main()
    else:
        return -1

if __name__ == "__main__":
    main()

#check output in your way.        

要查看或添加评论,请登录

Shivam Malviya的更多文章

  • java script to view current time

    java script to view current time

    Shivam Malviya save this file with file_name.html than check the output- Before onclick ???? After Onclick ????

  • Linear_search

    Linear_search

    you can check code here????????

  • QRCODE

    QRCODE

    view full details here ????????

  • Function

    Function

    YOU CAN VISIT OUR WEBSITE ??????

  • PYTHON JOURNEY

    PYTHON JOURNEY

    See my website??????

社区洞察

其他会员也浏览了