Guest User

Untitled

a guest
Jul 5th, 2017
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.05 KB | None | 0 0
  1. #Code your own Quiz
  2. #--> Fill in the blanks Quiz
  3. print "\n Welcome to my quiz about digitalization. Let's see if you can master the future.\n"
  4. print "\n Just type in the missing blanks: ___1___ ___2___ ___3___ ___4___ \n"
  5. print "How many attempts do you want to give yourself?"
  6. attempts = raw_input() #user has to input how many attempts he wants to play with
  7. attempts = int(attempts) #the number of attempts gets changed into an integer
  8.  
  9. #easy
  10. easy1 = "At the moment, ___1___ is one of the most important topics. It is also called ___2___. Studies predict that by 2020 there will be 200 billion connected devices on the ___3___ which also comes more and more in our everyday life thanks to smart devices like Amazon ___4___."
  11. easy2 = "The ___1___ economy is about owning the customer-supply interface. ___2___, the world's largest taxi company, owns no vehicles. ___3___, the world's most popular media owner, creates no content. And ___4___, the world's largest accommodation provider, owns no real estate."
  12. easy3 = "Only 42 percent of companies say they know how to extract meaningful insights from the ___1___ available to them. 87 percent of finance executives believe they need to analyze ___2___ and performance data much more quickly. Ten years from now, when we look back at how this era of ___3___ evolved...we will be stunned at how uninformed we used to be when we made decisions. - Billybosworth, DataStax CEO. By 2018, the data created by the Internet of Things devices will reach 403 trillion gigabytes a ___4___."
  13.  
  14. #medium
  15. medium1 = "73 percent of ___1___ believe the lack of employees with key technical skills is a threat to their company's growth. By 2019, approximately one quarter of the entire U.S. workforce will be independent (workers, independent contractor, ___2___, temp contractor, etc). 62 percent of ___3___ want their career to have a positive impact on the world, and 53 percent would work harder if their organization was making a difference to others. People are increasingly creating ___4___ incomes through online platforms and marketplaces like Airbnb, Etsy, Thumbtack, Uber and Upwork."
  16. medium2 = "The average internet user spends 1.72 hours on ___1___ per day. But only 39 percent of companies leverage use ___2___ to improve recruiting, engagement, and employer brand. There will be more words written on ___3___ in the next two years than contained in all books ever printed. ___4___ internet users are online approximately 3 times as long as Asian internet users."
  17. medium3 = "Businesses are no longer the sole creator of a ___1___; it is co-created by consumers through shared experiences and defined by the results of online searches and conversations. 70 percent of ___2___ are more likely to recommend a brand because it provides a simpler experience, and 38 percent are willing to pay more for simpler experiences. Brands that are loved by consumers, experience ___3___ appreciation 10 times more than brands that are less loved. 84 percent of global consumers actively seek out socially and ___4___ responsible brands, and 90 percent are willing to switch purchases to brands associated with a good cause."
  18.  
  19. #hard
  20. hard1 = "___1___ and ___2___ consumers are more than twice as likely to make purchases with their mobile phones, as consumers in the U.S., U.K., Japan, Germany and France. In the U.S., in-store payments with ___3___ will reach $808 billion by 2019, more than 21 times the $37 billion expected for 2015. 45 percent of shoppers who used their mobile device for ___4___ also used it for making a purchase."
  21. hard2 = "At the current turnover rate, 75 percent of the companies in the ___1___ in 2027, will be new (companies not currently in index today). By 2025, there will be 10 global ___2___ that will be considered mainstream. Their combined market value will exceed $5 trillion, and ___3___ will still be the largest. ___4___ will grow 200,000 percent from 2015 to 2030."
  22. hard3 = "There is now widespread agreement and emerging evidence, that access to ___1___ can help improve quality of life and accelerate development efforts at all levels. 38 million global deaths were due to ___2___ diseases. This invisible epidemic hinders the ___3___ of many countries. The first decade of this century witnessed a historic reduction in global poverty and a near doubling of the middle class, but 71 percent of the global population still subsists on less than $10 a day, and 1 billion people live on less than ___4___ a day."
  23.  
  24. #answers
  25. easy1_solutions = ["digitalization", "new economy", "internet of things", "Echo"]
  26. easy2_solutions = ["sharing", "Uber", "Facebook", "Airbnb"]
  27. easy3_solutions = ["data", "financial", "big data", "year"]
  28.  
  29. medium1_solutions = ["CEOs", "freelancer", "Millennials", "supplemental"]
  30. medium2_solutions = ["social networks", "social media data", "Twitter", "Latin American"]
  31. medium3_solutions = ["brand","consumers", "brand value", "environmentally"]
  32.  
  33. hard1_solutions = ["Chinese", "Indian", "mobile wallet apps", "social media"]
  34. hard2_solutions = ["S&P 500", "virtual currencies", "Bitcoin", "Crowd funding"]
  35. hard3_solutions = ["technology", "noncummunicable", "economic development", "2$"]
  36.  
  37. #blanks
  38. blanks = ["___1___", "___2___", "___3___", "___4___"]
  39.  
  40. #input_list
  41. input_list = ["easy", "medium", "hard"]
  42.  
  43. #global variables:
  44. easy_level = 0
  45. medium_level = 1
  46. hard_level = 2
  47.  
  48.  
  49. #function which is responsible for the structure of the difficulty easy; Input: easy-paragraphs and easy-solutions // Output: paragraphs with filled blanks
  50. #and congratulations if you win, but also game over if you do not have attempts left
  51. def easy():
  52. global attempts
  53. print "Your difficulty will be " + str(input_list[easy_level]) + ". Let's go!"
  54. print "\n Level 1\n"
  55. game(easy1, easy1_solutions, blanks) #executes the game function for the difficulty easy
  56. if attempts > 0:
  57. print "\n Level 2\n"
  58. game(easy2, easy2_solutions, blanks)
  59. else:
  60. return
  61. if attempts > 0:
  62. print "\n Level 3\n"
  63. game(easy3, easy3_solutions, blanks)
  64. print "\n Congratulations! You won! \n" #congrats the user, if he was able to figure out everything --> victory
  65. return "Designed and coded by Daniel Grittner"
  66. else:
  67. return
  68.  
  69. #function which is responsible for the structure of the difficulty medium; Input: medium-paragraphs and medium-solutions // Output: paragraphs with filled blanks
  70. #and congratulations if you win, but also game over if you do not have attempts left
  71. def medium():
  72. global attempts
  73. print "Your difficulty will be " + str(input_list[medium_level]) + ". Let's go!"
  74. print "\n Level 1\n"
  75. game(medium1, medium1_solutions, blanks) #executes the game function for the difficulty medium
  76. if attempts > 0:
  77. print "\n Level 2\n"
  78. game(medium2, medium2_solutions, blanks)
  79. else:
  80. return
  81. if attempts > 0:
  82. print "\n Level 3\n"
  83. game(medium3, medium3_solutions, blanks)
  84. print "\n Congratulations! You won! \n" #congrats the user, if he was able to figure out everything --> victory
  85. return "Designed and coded by Daniel Grittner"
  86. else:
  87. return
  88.  
  89. #function which is responsible for the structure of the difficulty hard; Input: hard-paragraphs and hard-solutions // Output: paragraphs with filled blanks
  90. #and congratulations if you win, but also game over if you do not have attempts left
  91. def hard():
  92. global attempts
  93. print "Your difficulty will be " + str(input_list[hard_level]) + ". Let's go!"
  94. print "\n Level 1\n"
  95. game(hard1, hard1_solutions, blanks) ##executes the game function for the difficulty hard
  96. if attempts > 0:
  97. print "\n Level 2\n"
  98. game(hard2, hard2_solutions, blanks)
  99. else:
  100. return
  101. if attempts > 0:
  102. print "\n Level 3\n"
  103. game(hard3, hard3_solutions, blanks)
  104. print "\n Congratulations! You won! \n" #congrats the user, if he was able to figure out everything --> victory
  105. return "Designed and coded by Daniel Grittner"
  106. else:
  107. return
  108.  
  109.  
  110. #Function with which the user decides the difficulty of the game. Input: easy, medium or hard // Output: strings, links to the game function in dependence of the difficulty
  111. def difficulty():
  112. print "Choose your difficulty by typing in easy, medium or hard:"
  113. user_input = raw_input() #user has to type in his difficulty he wants to play with
  114. print " "
  115. if user_input == input_list[0]: #this will be executed if the user types in easy
  116. easy()
  117. elif user_input == input_list[medium_level]: #this will be executed if the user types in medium
  118. medium()
  119. elif user_input == input_list[hard_level]:#this will be executed if the user types in hard
  120. hard()
  121. else: #if user_input not in input_list: #if the user does not type in easy, medium or hard, he receives an error message
  122. print "Error: You did not type in the required difficulty. Try again."
  123.  
  124.  
  125. #function for the game procedure; Input: the questions and solutions in dependence of the difficulty and the blanks-list//Output: strings like Level 1 (question paragraph) and the function also replaces the
  126. #blanks with the correct word, it is also responsible for the number of attempts
  127. def game(difficulty_questions, difficulty_solutions, blanks):
  128. print difficulty_questions
  129. index = 0
  130. length_of_list = 4
  131. global attempts
  132. while index < length_of_list: #loops through the blanks list until all blanks are filled
  133. print "\n"
  134. answer = raw_input("Number " + str(index + 1) + " is:") #user has to put in his answer for the blanks
  135. if answer == difficulty_solutions[index]:
  136. difficulty_questions = difficulty_questions.replace(blanks[index], difficulty_solutions[index]) #if he answers right, the blank gets replaced with the right solution
  137. index += 1
  138. else: #this gets executed when the player answers wrong
  139. if attempts == 1: #if he had one attempt left, he lost (1 - 1 = 0) --> Game over
  140. return "Game over!"
  141. else:
  142. attempts = attempts - 1 #this reduces the attempts if he answers wrong
  143. print "Attempts left: " + str(attempts)
  144. print "\n"
  145. print difficulty_questions
  146.  
  147.  
  148. difficulty()
Advertisement
Add Comment
Please, Sign In to add comment