Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using python Challenge 5: Write a program called ass2_5.py Now, we have five mountaineers who want to climb Mount Everest. We will use a random
Using python
Challenge 5: Write a program called ass2_5.py Now, we have five mountaineers who want to climb Mount Everest. We will use a random number generator, to determine the chances of how likely each of these mountaineers will make it to the final camp 5. (Don't worry, the random number generator code is written for you!) INITIALIZE VARIABLES Create 5 new variables called user1, user user3, user4, user5. Since all users have the same chance of reaching camp 5, initialize their values to the floating point value of 0.0. Create a new variable called direction. Initialize this value to INTEGER value of 0. Create a new variable called change. Initialize this value to FLOAT value of 0.0. PROCESSING: *** Read all the instructions below carefully before you start writing code!! (Why? Because it's pointless to write code, before you even understand the problem and what steps you need to take to solve it). Using a random number generator, we will roll a dice 3 times. This random generator code is written for you (Do not change). The random number generator will generate a random number between 1 and 6, simulating a dice roll. The first die roll determines the direction the user will go. If the first die roll is 1, 2, or 3, the user will go UP the mountain. In this case, store 1 into direction. Otherwise, the user will go DOWN the mountain. In this case, store -1 into direction. The second die roll determines how far the user will go. If the second die roll is 1 or 2, the user will go 2.0 steps in the direction determined by the first die. If the second die roll is 3 or 4, the user will go 4.0 steps in the direction determined by the first die. If the second die roll is 5 or 6, the user will go 6.0 steps in the direction determined by the first die. Store this value into the variable called change. The third die determines WHO (which user) we are talking about. If the third die roll is 1, we are talking about user1. Add the value of change to user's value. If the third die roll is 2, we are talking about user2. Add the value of change to user2's value. If the third die roll is 3, we are talking about user3. add the value of change to user3's value. If the third die roll is 4, we are talking about user4. Add the value of change to user4's value. If the third die roll is 5, we are talking about user5. Add the value of change to user5's value. If the third die roll is 6, do nothing. Do ALL of the above (everything in the "Processing" section) a total of 10 times. (Hint! Don't hardcode this 10 times, but rather use a loop!) OUTPUT: The code for printing the values of user user user user users is given to you. But! Your job is, in your code, add comments to explain what the string formatting is actually doing here. What does "%s" mean? What does%92r mean? (Your comment explanation will be graded for points, so don't forget to add comments!) Hint! Play around with string formatting by changing the numbers and see what changes in your output. You can also look in your textbook Section 2.5.3. page 51 SAMPLE INPUT AND EXPECTED OUTPUT: Since the random number generators will generate random numbers, your output might not look exactly like this. To test if your output is correct, you should see that for each iteration (out of the 10 times). only ONE user should have changed their value by either 2.0, 4.0, or 6.0 in a positive or negative direction Example 1: user1 0.06 useri 0.06 useri 0.00 useri 0.06 useri 0.00 User1 0.00 useri 0.06 useri 4.00 useri 10.08 useri 10.08 user2 0.00 user2 4.00 user2 4.00 user2 8.00 user2 8.00 user2 12.00 user2 12.00 user2 12.00 user2 12.00 user2 12.00 User3 0.00 user3 0.00 user3 0.00 user3 0.00 user3 0.00 user3 0.00 user3 6.60 user3 0.00 user3 0.00 user4 6.00 user4 0.00 user4 -4.00 user4 -4.00 user4 -6.00 user4 -6.00 user4 -6.00 user4 -6.00 user4 -6.00 user4 -6.00 user5 -6.00 user5 -6.00 user5 -6.00 user5 -6.00 user5 -6.00 user 5 -6.00 users - 12.00 user5 - 12.00 user5 - 12.00 user5 - 16.00 user3 0.00 Example 2: User1 0.00 user1 0.00 user1 0.00 useri 0.00 useri 0.00 useri 2.00 User1 2.00 useri 2.00 useri 2.00 useri 2.00 user2 0.00 user2 0.00 user2 0.00 user2 4.00 user 2 6.08 user2 6.00 user2 6.00 user2 6.00 user2 8.00 user2 10.00 user3 0.00 user3 4.00 user3 4.06 user3 4.00 user3 4.00 user3 4.00 user3 4.00 user3 4.00 user3 4.00 user3 4.00 user4 -6.00 user4 -6.00 user4 -6.06 user4 -6.08 user4 -6.06 user4 -6.00 User4 -6.00 user4 -6.00 user4 -6.00 user4 -6.00 users 0.00 user5 0.00 user 5 -2.00 user5 -2.00 user5 -2.00 user5 -2.00 users -8.00 user5 - 12.00 user5 -12.00 user5 - 12.00Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started