python - Need help on a simple quiz with random answers -


This is my code, why would not it work for me? This question asks, but if I made, I remembered from that time.

  print ("what is your name?") Name = input ("") import time time.sleep (1) print ("hello", name, (", in my quiz Welcome ")) Import time. Sleep (1) import random questions [['2 times 2 what is?', '10 is what (7) '6 times 2?'] Print (random. Chouse (question)) Please note that if there are statements So if == ('2 times 2 will happen?'): Print ("What is the answer?") Answer = Input ("") If ans == '4': Print ("true") Second: Print ("wrong") elif ques == ('10x7? '): Print ("what is the answer?") Answer = Input ("") if ans ==' 70 ': print ("true") other : Print ("wrong") elif ques == ('what happens 6 times 2?'): Print ("What is the answer Land? ") Ans = input (" ") if ans == '12': print (" right ") else: print (" wrong ") import periods of time. Sleep (1) Import random questions ['55 What moves 20? ',' What is divided by 2 60? ',' 500 takes what 200 '] Print (random. Choice (x)) If ques == ('55 what takes 20? '): Print ("What is the answer? (" Right ") Other: Print (" wrong ") elif ques == (What is the breakdown from 60?): Print ("What is the answer?") Answer = input ("") if ans == '30': print ("true") second: print ("wrong") elif ques == ('500 takes 200' ): Print ("What's Right?") Ans = Input ("") if ans == '300': Print ("True") Other: Rint ("false")    

ques still complete If you want to use this method for an element of the list, then I suggest doing the following:

  posedQuestion = random.choice (ques) Ask the question asked if the printed question (posedQuestion) == "first question": elif ...   

In addition to this, you have to import only once, so only one line Import time must be ;)

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -