Question

In: Computer Science

Use Python to solve: show all work 1) Write a program that prints out a deck...

Use Python to solve: show all work

1) Write a program that prints out a deck of cards, in the format specified below. (That is, the following should be the output of your code).

2 of hearts

2 of diamonds

2 of spades

2 of clubs

3 of hearts

3 of diamonds

3 of spades

3 of clubs

4 of hearts

4 of diamonds

4 of spades

4 of clubs

Continue with 5,6,7.. ending with

A of hearts

A of diamonds

A of spades

A of clubs

Start your program by defining the following two lists.

suits = ["hearts", "diamonds", "spades", "clubs"]

ranks = [“2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “10”, “J”, “Q”, “K”, “A”]

Remember you can use the for statement to get elements of a list.

For example if lst = ["A","B","C"] then

for elem in lst:

    print (elem)

would print

A

B

C

Solutions

Expert Solution

PYTHON CODE:

# list to store the suits
suits = ["hearts", "diamonds", "spades", "clubs"]

# list to store the ranks
ranks = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"]

# iterating through the rank list
for rank in ranks:

    # iterating through the suit list
    for suit in suits:

        # printing the string in the required format
        print("{0:s} of {1:s}".format(rank,suit))

SCREENSHOT FOR CODING:

SCREENSHOT FOR OUTPUT:


Related Solutions

Use Python to solve, show all code Write a program that sums a sequence of integers...
Use Python to solve, show all code Write a program that sums a sequence of integers from a starting integer to and ending integer. The sequence is generated by skipping a value (e.g. 1,3,5,… or 2,6,10,14…). Prompt the user for a) a starting value greater than 0. Validate the value is greater than 0. b) the ending value. c) the value to skip Print out the sum of the numbers for the sequence. If the starting value is 2, the...
In Python write a program that calculates and prints out bills of the city water company....
In Python write a program that calculates and prints out bills of the city water company. The water rates vary, depending on whether the bill is for home use, commercial use, or industrial use. A code of r means residential use, a code of c means commercial use, and a code of i means industrial use. Any other code should be treated as an error. The water rates are computed as follows:Three types of customers and their billing rates: Code...
Write a program that asks the user for an integer and then prints out all its...
Write a program that asks the user for an integer and then prints out all its factors. For example, when the user enters 84, the program should print 2 2 3 7 Validate the input to make sure that it is not a character or a string using do loop.in c++
Use Python to solve: show all code: 2) For the last assignment you had to write...
Use Python to solve: show all code: 2) For the last assignment you had to write a program that calculated and displayed the end of year balances in a savings account if $1,000 is put in the account at 6% interest for five years. The program output looked like this: Balance after year 1 is $ 1060.0 Balance after year 2 is $ 1123.6 Balance after year 3 is $ 1191.02 Balance after year 4 is $ 1262.48 Balance after...
Write a C++ program that prints out all of the command line arguments passed to the...
Write a C++ program that prints out all of the command line arguments passed to the program. Each command line argument should be separated from the others with a comma and a space. If a command line argument ends in a comma, then another comma should NOT be added
Write a program that prints out all numbers, less than or equal to 10,000,000, that are...
Write a program that prints out all numbers, less than or equal to 10,000,000, that are evenly divisible by all numbers between 5 and 15 (inclusive). Do not use any libraries besides stdio.h. Need it in 10 minutes, please.
Write a program in PYTHON which: *Defines the following 5 functions: whoamI() This function prints out...
Write a program in PYTHON which: *Defines the following 5 functions: whoamI() This function prints out your name and PRINTS OUT any programming course you have taken prior to this course. isEven(number) This function accepts one parameter, a number, and PRINTS OUT a message telling if the numberer is even or odd. Keep in mind that a number is even if there is no remainder when the number is divided by two. printEven(number) This function accepts one parameter, a number,...
Use if statements to write a Java program that inputs a single letter and prints out...
Use if statements to write a Java program that inputs a single letter and prints out the corresponding digit on the telephone. The letters and digits on a telephone are grouped this way: 2 = ABC    3 = DEF   4 = GHI    5 = JKL 6 = MNO   7 = PRS   8 = TUV 9 = WXY No digit corresponds to either Q or Z. For these 2 letters your program should print a message indicating that they are not...
use Python datetime module, strftime Write a program that processes the following textfile and prints the...
use Python datetime module, strftime Write a program that processes the following textfile and prints the report shown below. Textfile: Ask the user for the filename and BE SURE TO CHECK THAT IT EXISTS. The file will contain lines which each contain 2 strings (bookTitle and publicationDate) separated by a comma and a space. Note that the title of the book might contain spaces! Example of the textfile: Gone Girl, 5-24-2012 To Kill A Mockingbird, 7-11-1960 Harry Potter and the...
Please write the following Python program. Also, show all output work. Computing the Fibonacci and Lucas...
Please write the following Python program. Also, show all output work. Computing the Fibonacci and Lucas Series¶ Goal:¶ The Fibonacci Series is a numeric series starting with the integers 0 and 1. In this series, the next integer is determined by summing the previous two. This gives us: 0, 1, 1, 2, 3, 5, 8, 13, ... We will write a function that computes this series – then generalize it. Step 1¶ Create a new module series.py in the session02...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT