Unit 5

Exercise 1. Write a program that uses a for-loop to print 20 random numbers ranging from 1 to 50.

Exercise 2. Write a program that uses a for-loop to print 20 random numbers ranging from 50 to 100.

Exercise 3. Write a program that uses a for-loop to simulate 50 coin tosses using the random.random() function and displays the (sum of) number times Heads and the number of times Tails is tossed. Heads occurs when the random number is greater then 0.5.

Exercise 4. Write a program that uses a for-loop to simualate 50 rolls of one die summing the amount of times a 1, 2, 3, 4, 5 and 6 is rolled.

Exercise 5. Write a program that uses a for-loop to simualate 50 rolls of two dice summing the amount of times a 2, 3, 4, and so on to 12 is rolled.

Exercise 6. Write a program where the computer chooses a random number between 1 thru 10 and using a while-loop a user guesses the number until the user inputs the correct computer's number.

Exercise 7. Write a program that simulates the Shell Game
where using a while-loop the computer chooses a random number between 1 thru 3 representing the cup the nut is under and a user guesses the number of the cup, until the user inputs the correct cup number.Remember the nut changes its random cup each time the loop executes, meaning the nut does not necessarly stays under the same cup.