Question: Question 1 : Draw a playing card ( 2 5 marks ) a ) For this question, you will build six helper functions and one

Question 1: Draw a playing card (25 marks)
a) For this question, you will build six helper functions and one main function that must work together to draw a playing card of any suit from ranks Ace to Nine. As you write your program, test each function individually by calling it with different function calls. Only move on to the next function once you are certain that your current function works. Remember, every line of code written should be inside of a function. Here are the criteria:
Your program "
L5Q1initials.py" must start with a commented academic integrity pledge, ID Box, and program purpose. EACH of the six helper functions as well as the main function must state its purpose in comments. Documentation matters!
Only Python syntax taught in lecture and/or lab is permitted in lab submissions.
Here are the function specifications:
Helper function: draw_top ()
The first helper function has been provided for you. Copy this function into your program EXACTLY as written. The screenshot provided shows one function call using this function. Try calling it with other function calls so you are sure how it works.
# Purpose: Draw the top border of the card as well as
4 the rank in tife top left corner
def draw_top (rank):
print{""+ tin""}
print("|" totank +6*""+"|")
Helper function: draw_symbols ()
draw_symbols {num, symbo1}:
This function will draw the number of symbols indicated (between zero to three) on one line. The symbols will be space separated and appear centered within the edge borders. There MUST always be nine characters per line, counting symbols, spaces, and edges ("|"). Refer to the screenshot for examples.
NOTE: The table below shows the Unicode string for each French card suit.
\table[[Name,Unicode,Symbol],[Club,'u2663',],[Diamond,'U2666',],[Heart,'U2665',],[Spade,Iu2660",]]
Helper function: draw_mid()
draw_mid(num_outer, num_mid, symbol): This function will call draw_symbols () three times in succession, drawing the first and third lines using num_outer and the second line using num_mid.
Helper function: draw_bot ()
draw_bot (rank):
This function will print the bottom border of the card followed by the card rank between the two edge borders all on the same line ensuring the line contains exactly nine characters. Then it will print a blank line. Refer to the screenshot for details.
Helper function: rank_input ()
rank_input ():
This function will prompt the user for a card rank between 1(Ace) to 9 and return the rank as a string. Assume the user will type in a number between 1 and 9 inclusive or the letter "A" or "a". Regardless of the usertyping "1" or "A" or "a", the function must return the rank as "A". No other error checking is required.
rank = rank_input()
Enter card rank (A-9):1
print(rank)
A
rank = rank_input ()
Enter card rank (A-9):9
print (rank)
9
Helper function: suit_input ()
su1t_imput ():
This function will prompt the user for a card suit. The choices are 'C','D','H', and 'S' for Club, Diamond, Heart, and Spade respectively. The input should be error-checked (using a loop) to ensure it is valid and it should NOT be casesensitive. The function will determine and return the Unicode character of the chosen suit as a string (refer to the table provided previously).
Do not use the ' in' operator in your solution.
Main function: main ()(must call ALL helper functions except draw_symbols)
main():
The main function must call rank_input () and suit input () to obtain respective inputs from the user and call draw_top, draw_mid, and draw_bot appropriately to draw the correct playing card using the information given. This function should not have any print statements at all.
The sample output provided shows you sample outputs for each rank (make sure that the positions of cach symbol match that of the screenshots). Otherwise, your output should be similar, but reflect the rank and suit given.
Sample runs:
Other Notes: Fonts
Ensure that your IDE is using a font with consistent character size and spacing to ensure that the card sections correctly line up. Wing's default font, Consolas, works correctly. To change the font on Wing, go to Edit > Preferences > User Interface > Fonts, and ensure that "Use Default" is enabled for both the display and editor fonts.
b) Save your program as "
L5Q1initials.py" replacing initials with your actual initials.
c) Submit your program electronically for marking (unless otherwise instructed).
 Question 1: Draw a playing card (25 marks) a) For this

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!