Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab 5: Functions, COSC 1336 Programming Fundamentals I, Python Kathryn Rehfield Lab 5: Functions Due: 07/03/17 Last day accepted for half credit: 07/07/17 Add to

Lab 5: Functions,

COSC 1336 Programming Fundamentals I, Python

Kathryn Rehfield

Lab 5: Functions Due: 07/03/17 Last day accepted for half credit: 07/07/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:

Make Change

High Card

Deal Hand

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:

A typed algorithm for your program named lab5_algorithm_Firstname_Lastname which will include a separate algorithm for each function:

Main

Menu

Make Change

High Card

Deal Hand

Display Face Value

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:

You will NEVER call main() more than once.

You will NEVER use pass, continue, break, exit, quit, end or ANYTHING to leave a loop, function, or other construct prematurely.

You will NEVER have a function call itself.

You will NEVER use global variables. However, you may use global constants if used properly.

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 Grade Points

Algorithm 30 points

Comments 15 points

program description

major algorithm steps

function descriptions

Followed directions 15 points

Correct output 15 points

Structured program design 20 points

Meaningful identifier names 5 points

Program descriptions should look similar to this:

################################################# # Clovis Bagwell # # Lab 1 # # This program prompts the user for a positive integer # # and displays a message whether it is prime or not. #

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Inference Control In Statistical Databases From Theory To Practice Lncs 2316

Authors: Josep Domingo-Ferrer

2002nd Edition

3540436146, 978-3540436140

More Books

Students also viewed these Databases questions