Creating a Quiz with Streamlit

Hello guys,

Im trying to create a Streamlit app, to a friend of mine, in her company they need that every new candidate answer 55 questions of multiple choice, and them the Intern cheque the answers.

Hi @Judsonpp,

Thank you for sharing with the Streamlit community! I would recommend checking out our Cookbook documentation on input widgets and our documentation on streamlit.radio, which can be used to create radio buttons.

Feel free to let us know if you have any further questions after reviewing those pages and the included code snippets.

Best,

Caroline

Hi Caroline,

We are trying to generate a quiz application using streamlit. Please find the code attached here:

fill_in_the_blanks = {'questions': ['question1','question2'], 'answers': ['answer1','answer2']}
ans = []
mark = 0
with st.form(key = id_generator()):
	for i,quest in enumerate(fill_in_the_blanks["questions"]):
		st.write(i+1,quest)
		x = st.text_input("Enter your answer here",key=id_generator())
		ans.append(x)
	submitted = st.form_submit_button(label='Submit')
	if submitted:
		# if answers are correct then
			mark = mark+1
	st.success("Test Score - "+str(mark))

Here, i am able to populate questions within the form widget. But, am not able to read text_input answers which is created with the help of for loop. How to read text_input value from user in this case. Please do the needful here.

Thanks,
Prakash
mail: prakash@deepsphere.ai

1 Like