import time
QA = [
("1.After the emperor was overthrown, what two political parties emerged in China?\na. Republican & Democrats\nb. Nationalist & Communist\nc. Fascists & Socialsts\nd. The People for Republic of China & The Japanese Communist Party","b","Nationalist & Communist"),
("2.Who was the leader of the Communist party?\na. Mao Zedong\nb. Deng Xiaoping\nc. George W. Bush\nd. Emperor Hirohito","a", "Mao Zedong"),
("3.What did the Communist party promise to bring to China?\na. More freedom of speech\nb. Freedom of religion\nc. Food to the poor and more wealth to all Chinese, and land reforms\nd. More personal freedoms","c","Food to the poor and more wealth to all Chinese, and land reforms"),
("4.When was the Communist state of the People’s Republic of China established\na. 1900\nb. 1989\nb. 2008\nd. 1949","d","1949"),
("5.Why did poor peasants support the Chinese Communist Party?\na. They wanted to work in communes\nb. It promised them food and a better quality of life\nc. They had no other option\nd. Mao Zedong said he would give them money","b","It promised them food and a better quality of life"),
("6.Which country was China’s key ally throughout the mid-1900s\na. Japan\nb. India\nc. The U.K.\nd. Soviet Union","d","Soviet Union"),
("7.What was the name of the economic plan that the Chinese government developed in order to boost China’s economy?\na. Great Leap Forward\nb. The Cultural Revolution\nc. China's Betterment Plan\nd. Chinese Economic Plan for that moolah","a","Great Leap Forward"),
("8.What three problems caused the Great Leap Forward to fail within a year?\na. Lack of funds, people, and resources\nb. Too much money, food, and resources\nc. Too much government control, too much money, and the people were too eager to work\nd. Environmental disasters, poor government management, and government corruption","d","Environmental disasters, poor government management, and government corruption"),
("9.What was the biggest consequence of the Great Leap Forward?\na. Famine, 20 million people died\nb. The economy was boosted\nc. China became a player in the international setting\nd. Chinese citizens were given more freedoms.","a","Famine, 20 million people died"),
("10.When was the Communist state of the People’s Republic of China established\na. 1900\nb. 1989\nb. 2008\nd. 1949","d","1949"),
("11.Which two political parties emerged in China after the Emperor was overthrown, following the end of WW2? ( Pick 2)\na. Nationalist\nb. Communist\nc. Democratic\nd. Republican","b","Communist"),
("12.When Mao died in 1976, who became the leader of China?\na. Hirohito\nb. Sun Yixian\nc. Ho Chi Minh\nd. Den Xiaoping","d","Den Xiaoping"),
("13.How successful was the Great Leap Forward?\na. Very successful\nb. Successful\nc. Not that successful\nd. An EPIC disaster","d","An EPIC disaster"),
("14.What is the name of the army of young students that Mao used to enforce policies in the 1960's?\na. The Red Guard\nb. Hitler Youth\nc. The Youth for Communism\nd. The great Collective","a","The Red Guard"),
("15.Which country was China’s key ally throughout the mid-1900s\na. Japan\nb. India\nc. The U.K.\nd. Soviet Union","d","Soviet Union"),
("16.In China there was a time when Mao wanted to eliminate anyone that criticized his government. What is this time called?\na. Long March\nb. The Middle Way\nc. The Great Leap Forward\nd. The Cultural Revolution","d","The Cultural Revolution"),
("17.When did Mao and the Communists take control of China?\na. Right after WWII\nb. in the 1930's\nc. the end of WWI\nd. during WWII","c","the end of WWI"),
("18.Which of the following describe why the Great Leap Forward was unsuccessful?\na. People refused to move to larger farms.\nb. People wanted to be able to work for themselves and make a profit.\nc. Chinese farmers did not know how to plant crops on large plots of land.\nd. The Communist government rejected Mao's Idea and farms were never organized.","b","People wanted to be able to work for themselves and make a profit."),
("19.Which of the following would happen only in a communist economy?\na. The government promotes competition\nb. The government provides incentives for innovation\nc. The government emphasizes the production of consumer goods\nd. The government controls all business activities","d","The government controls all business activities"),
("20.The loyalty to a group with whom one shares common history, culture, and or religion.\na. Cultural Revolution\nb. Nationalism","b","Nationalism"),
]
score = 0
life = 3
for question, short_ans, long_ans in QA:
answer1 = input(question + "\nAnswer:")
start = time.time()
if answer1 in (short_ans, long_ans):
score += 1
print("Correct!\nScore:", score, "\nLife:", life, "\n")
end = time.time()
print('[*] Running time: {} seconds.'.format(end-start), "\n")
elif answer1 == "stop" or life == 0:
print("\nGAME OVER!")
break
else:
life -= 1
print("Wrong! The answer is ", short_ans, long_ans, "\nScore", score, "\nLife:", life, "\n")
end = time.time()
print('[*] Running time: {} seconds.'.format(end-start), "\n")
I did something like that, but I still didn't understand what's wrong with variable "life" and why decorator time doesn't work
Problem N1: If user answer wrong 3 times in a row then the game should stop and prompt "Game over!". But I still can't understand how to make it out.
Problem N2: How to output the time of answering the question?