Rohith123abc/string_operations
0
1import streamlit as st2import random3 4# List of questions and answers5quiz = [6 {"question": "What is the capital of France?", "answer": "Paris"},7 {"question": "Who wrote 'To Kill a Mockingbird'?", "answer": "Harper Lee"},8 {"question": "What is the square root of 16?", "answer": "4"},9 # Add as many questions as you like...10]11 12# Select a random question13question = random.choice(quiz)14 15# Display the question16st.write(f"Question: {question['question']}")17 18# Get the user's answer19answer = st.text_input('Your Answer')20 21# Check the answer22if st.button('Check Answer'):23 if answer.lower() == question['answer'].lower():24 st.write('Correct!')25 else:26 st.write(f"Sorry, that's incorrect. The correct answer is {question['answer']}.")27 