Question: For Python Could you help me with these assigments exercise 4.14, 4.15, and 4.16 back to square 1. Animal Move type Percentage of the time


back to square 1. Animal Move type Percentage of the time Actual move Tortoise Hare Fast plod Slip Slow plod Sleep Big hop Big slip Small hop Small slip 50% 20% 30% 20% 20% 10% 30% 20% 3 squares to the right 6 squares to the left 1 square to the right No move at all 9 squares to the right 12 squares to the left 1 square to the right 2 squares to the left Create two functions that generate the percentages in the table for the tortoise and the hare, respectively, by producing a random integer i in the range 1 Sis 10. In the function for the tortoise, perform a "fast plod when 1 Sis5, a "slip" when 6 Sisor a "slow plod" when & Sis 10. Use a similar technique in the function for the hare. Begin the race by displaying BANG !!!!! AND THEY'RE OFF !!!!! Then, for each tick of the clock (i.e., each iteration of a loop), display a 70-position line showing the letter "T" in the position of the tortoise and the letter "H" in the position of the hare. Occasionally, the contenders will land on the same square. In this case, the tor- toise bites the hare, and your application should display "OUCH!!!" at that position. All positions other than the "T", the "H" or the "OUCH!!!" (in case of a tie) should be blank. After each line is displayed, test for whether either animal has reached or passed square 70. If so, display the winner and terminate the simulation. If the tortoise wins, dis- play TORTOISE WINS!!! YAY!!! If the hare wins, display Hare wins. Yuch. If both ani- mals win on the same tick of the clock, you may want to favor the tortoise (the "underdog"), or you may want to display "It's a tie". If neither animal wins, perform the loop again to simulate the next tick of the clock. When you're ready to run your application, assemble a group of fans to watch the race. You'll be amazed at how involved your audience gets! 4.13 (Arbitrary Argument List) Calculate the product of a series of integers that are passed to the function product, which receives an arbitrary argument list. Test your func- tion with several calls, each with a different number of arguments. 4.14 (Computer-Assisted Instruction) Computer-assisted instruction (CAI) refers to the use of computers in education. Write a script to help an elementary school student learn multiplication. Create a function that randomly generates and returns a tuple of two pos- 154 Functions itive one-digit integers. Use that function's result in your script to prompt the user wich question, such as How much is 6 times 7? For a correct answer, display the message "Very good!" and ask another multiplication question. For an incorrect answer, display the message "No. Please try again." and le. the student try the same question repeatedly until the student finally gets it right. 4.15 (Computer-Assisted Instruction: Reducing Student Fatigue) Varying the combur. er's responses can help hold the student's attention. Modify the previous exercise so that various comments are displayed for each answer. Possible responses to a correct answer should include 'Very good!', 'Nice work!' and 'Keep up the good work!' Possible re- sponses to an incorrect answer should include 'No. Please try again.', 'Wrong. Try once more.' and 'No. Keep trying.' Choose a number from 1 to 3, then use that value to select one of the three appropriate responses to each correct or incorrect answer. 4.16 (Computer-Assisted Instruction: Difficulty Levels) Modify the previous exercise to allow the user to enter a difficulty level. At a difficulty level of 1, the program should use only single-digit numbers in the problems and at a difficulty level of 2, numbers as large as two digits. 4.17 (Computer-Assisted Instruction: Varying the Types of Problems) Modify the previ- ous exercise to allow the user to pick a type of arithmetic problem to study-1 means ad- dition problems only, 2 means subtraction problems only, 3 means multiplication problems only, 4 means division problems only (avoid dividing by 0) and 5 means a ran- dom mixture of all these types. 4.18 (Functional-Style Programming: Internal vs. External Iteration) Why is internal iteration preferable to external iteration in functional-style programming? 4.19 (Functional-Style Programming: What vs. How) Why is programming that em- phasizes what" preferable to programming that emphasizes "how"? What is it that makes "whar" programming feasible? 4.20 (Intro to Data Science: Population Variance vs. Sample Variance) We mentioned in the Intro to Data Science section that there's a slight difference between the way the statistics module's functions calculate the population variance and the sample variance. The same is true for the population standard deviation and the sample standard deviation. Research the reason for these differences
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
