Question: Question 1 : Draw a playing card ( 2 5 marks ) a ) For this question, you will build six helper functions and one
Question : Draw a playing card 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
LQinitials.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 andor lab is permitted in lab submissions.
Here are the function specifications:
Helper function: drawtop
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
the rank in tife top left corner
def drawtop rank:
print tin
print totank
Helper function: drawsymbols
drawsymbols num symbo:
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.
tableNameUnicode,SymbolClubuDiamondUHeartUSpadeIu
Helper function: drawmid
drawmidnumouter, nummid, symbol: This function will call drawsymbols three times in succession, drawing the first and third lines using numouter and the second line using nummid.
Helper function: drawbot
drawbot 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: rankinput
rankinput :
This function will prompt the user for a card rank between Ace to and return the rank as a string. Assume the user will type in a number between and inclusive or the letter or a Regardless of the usertyping or or the function must return the rank as No other error checking is required.
rank rankinput
Enter card rank :
printrank
A
rank rankinput
Enter card rank :
print rank
Helper function: suitinput
sutimput :
This function will prompt the user for a card suit. The choices are CDH and S for Club, Diamond, Heart, and Spade respectively. The input should be errorchecked 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 drawsymbols
main:
The main function must call rankinput and suit input to obtain respective inputs from the user and call drawtop, drawmid, and drawbot 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
LQinitials.py replacing initials with your actual initials.
c Submit your program electronically for marking unless otherwise instructed
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
