Question: Lab 4: Repetition COSC 1336 Programming Fundamentals I,Python Add to lab 3: Lame Game Computer Game Room. Be sure to update the part of your

Lab 4: Repetition COSC 1336 Programming Fundamentals I,Python Add to lab 3: Lame Game Computer Game Room. Be sure to update the part of your program that describes to the user what the program will do. Make any necessary updates to your make_change game. You will have a loop in your program to control displaying the menu and playing the games. Continue to re-display the menu, read a menu option and play a game until the user enters option 3 (quit). You will now implement the High Card game. You will write a code to randomly generate two playing cards using the following rules: 1 = ace 2 10 = number cards 11 = jack 12 = queen 13 = king Your high_card game will ask for the first name of each player to be used when displaying the results. For purposes of this game, Ace is the lowest card. This game will deal two cards, one to each of the two players, and display the face value of player ones card and player twos card. The game will then display which player got the highest card or if it is a tie. When the High Card game is played, the output should look similar to this: Enter player 1s name: Slydelle Enter player 2s name: Kimminy Slydelle got a Seven Kimminy got a King Kimminy is the winner You will simulate dealing a card by generating a random number between 1 and 13. To use the random number generating function randint, you will need to import the module containing the code for the function. Put this line at the top of your file just under your program header comment block: import random To deal a card you will use the following statement: card1 = random.randint(1, 13) card2 = random.randint(1, 13) You can read more about the function in chapter 5 on pages 197-198. Your program will display the face value of each playing card. The decision will be based on the numeric value of the card and will display the face value using the following rules: 1 display Ace 2 thru 10 display Two, Three, etc. 11 display Jack 12 display Queen 13 display King You will now use an input validation loop to ensure the users choice is valid. If the user enters an invalid option, display an error message, and re-prompt for users choice. You will submit the following in Blackboard: Your program source code - Not a copy pasted into a word processing document named lab4_Firstname_Lastname.py NOTE Violating any of the following is grounds for getting a ZERO on your lab: 1. You will NEVER call main() more than once. 2. You will NEVER use pass, continue, break, exit, quit, end or ANYTHING to leave a loop, function, or other construct prematurely. 3. You will NEVER have a function call itself. 4. You will NEVER use global variables. However, you may use global constants if used properly. 5. You will have only one return statement in a function. NOTE Once your lab grade has been posted in Blackboard, you will have access a copy of my solution attached to your grade. Lab 5: Functions COSC 1336 Programming Fundamentals I,Python Kathryn Rehfield Lab 5: Functions Due: 07/06/17 Last day accepted for half credit: 07/09/17 Add to lab 4: Lame Game Computer Game Room. You will now put your welcome message/program description for the user into a void function. Be sure to update your description to include the new features, if any. Make any necessary updates to your program after reviewing the feedback from your previous lab. You will start organizing your code into functions. You will start by moving the central part of your code into a main function, if you have not already. This function will just be a loop that executes until the user enters the option to quit. You will create a value-returning function with all the code that 1) displays the menu and 2) makes sure the user entered a valid choice. This new menu function will not take any input, but will pass back to the calling function a valid menu choice. (Remember that program input and output is not the same thing as function input and output. Function input is what is passed in on the parameter list, NOT reading data from the keyboard. Function output is anything returned to the calling function whether it is on the parameter list or in a return statement.) You will move the code to display the face value of a card into a new function called display_face_value(). This function will take as input one numeric card value. The function will then display the one word face value of the card passed in. This function will not pass back anything to the calling function. Pay attention to the words in bold and follow the directions. I have reasons for having you do this a specific way. Adding a new option to your menu (3. Deal Hand), you will now have the following options: 6. Make Change 7. High Card 8. Deal Hand 9. Quit Make Change and High Card will now be moved into their own functions. So, if the user enters option 1, your main will call make_change(). If the user enters option 2, your main will call high_card(). When chosen, option 3 will call the deal_hand function. This function will generate, or deal an entire 5-card hand. You will declare 5 new variables, one for each card in a 5-card hand. Once all 5 cards have been dealt, display the face value for each of the cards in the hand. You will use your new display_face_value function to do this. You will have to call it once for each card. Again, I have reasons for having you do this a specific way, so be sure you follow the directions. You will submit the following in Blackboard: j. A typed algorithm for your program named lab5_algorithm_Firstname_Lastname which will include a separate algorithm for each function: i. Main ii. Menu iii. Make Change iv. High Card v. Deal Hand vi. Display Face Value k. Your program source code - Not a copy pasted into a word processing document named lab5_Firstname_Lastname.py NOTE Violating any of the following is grounds for getting a ZERO on your lab: 1. You will NEVER call main() more than once. 2. You will NEVER use pass, continue, break, exit, quit, end or ANYTHING to leave a loop, function, or other construct prematurely. 3. You will NEVER have a function call itself. 4. You will NEVER use global variables. However, you may use global constants if used properly. 5. You will have only one return statement in a function. Lab 6: Files COSC 1336 Programming Fundamentals I,python Add to lab 5: Lame Game Computer Game Room Be sure to update the function in your program that describes to the user what the program will do. Make any necessary updates to your program after reviewing the feedback from your last lab. Add a try/except statement to your menu function to catch a ValueError in case the user enters character data when prompted for the menu option. Adding to your menu, you will now have the following options: 6. Make Change 7. High Card 8. Deal Hand 9. Save Dream Hand 10. Display Dream Hand 11. Quit The Make Change, High Card and Deal Hand functions should remain the same. Option 4 (Save Dream Hand) will call a function that asks the user for their dream hand of 5 cards. You should ask for the numeric value (user enters a 1 for an Ace, 2 for a Two, etc.). Once you have read and validated all 5 cards, the function will then ask user for a file name and save the cards to the file, one card on each line. Use a try/except statement to display an error message if a ValueError is encountered due to the user entering character data when prompted for a card. Option 5 (Display Dream Hand) will call a function that asks the user for a file name, opens the file, reads all 5 cards in the file into 5 separate variables. Then the function displays the face value of each card. Use a try/except statement to display an error message if an IOError is encountered due to a bad file name. You will submit the following in Blackboard: l. A typed algorithm for your program named lab6_algorithm_Firstname_Lastname which will include a separate algorithm for each function all in one file: . Main i. Menu ii. Make Change iii. High Card iv. Deal Hand v. Display Face Value vi. Save Dream Hand vii. Display Dream Hand m. Your program source code named lab6_Firstname_Lastname.py NOTE Violating any of the following is grounds for getting an F on your lab: 1. You will NEVER call main() more than once. 2. You will NEVER use break, exit, quit, stop, continue, pass or anything to leave a loop, function, or other construct prematurely. 3. You will NEVER have a function call itself. 4. You will NEVER use global variables. However, you may use global constants if used properly. 5. You will have only one return statement in a function.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!