Question
*python programming assignment* Write a program that prints a table listing the number of possible hands of r cards, where r ranges from 0 to
*python programming assignment*
Write a program that prints a table listing the number of possible hands of r cards, where r ranges from 0 to 52.
Your solution MUST include:
This function must make use of the function factorial(num) that you wrote.
a user-defined function called factorial(num).
argument: num, an integer representing the number you want the factorial of.
return value: the integer value (num!), the factorial of num.
Note that you must write this function yourself; do not use any built-in functions to calculate the factorial. Use an algorithm similar to the one we wrote in class.
a user-defined function called combinations(n,r).
argument: n, an integer representing the number of cards in the deck.
argument: r, an integer representing the number of cards to draw from the deck to create a hand.
return value: the integer value n! / (r! (n-r)!), the number of combinations of r cards that can be dealt from a deck of n cards.
a main program that prints the table by:
printing a header.
calling combinations(n,r) 53 times, each time printing one line of the table.
Expected output:
Your output should look exactly like the following (except with additional lines of the table instead of the ellipses):
Cards Combinations ====================== 0 1 1 52 2 1326 3 22100 4 270725 5 2598960 . . . 47 2598960 48 270725 49 22100 50 1326 51 52 52 1
Important Notes on Formatting:
Formatting of the output is an important part of your grade on this assignment. If you've done this correctly:
The value of "cards" in each line of the table will line up, right-justified, and there will always be at least one blank between the number and the left edge of the table.
The value of "combinations" in each line of the table will line up, right-justified, and in the line with the largest number of combinations, there will be exactly four spaces between the number of cards and the number of combinations.
There should be one blank line above the table and one blank line below the table.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started