1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Travka [436]
3 years ago
14

Write a program that takes user input describing a playing card in the following short-hand notation:

Computers and Technology
1 answer:
siniylev [52]3 years ago
6 0

Answer:

In python Language:

cardNotation = raw_input("Enter card notation: ")

 

# Create a dict for values

 

cardColors = {"D": "Diamonds",

             "H": "Hearts",

             "S": "Spades",

             "C": "Clubs"}

 

cardNumberValues = {"A": "Ace",

                   "J": "Jack",

                   "Q": "Queen",

                   "K": "King",

                   "2": "Two",

                   "3": "Three",

                   "4": "Four",

                   "5": "Five",

                   "6": "Six",

                   "7": "Seven",

                   "8": "Eight",

                   "9": "Nine",

                   "10": "Ten"}

 

# Handle cases when 10 comes in input

if len(cardNotation) == 3:

 

   number = cardNotation[:2]

   color = cardNotation[2:]

   print cardNumberValues.get(number) + " of " + cardColors.get(color)

 

elif len(cardNotation) == 2:

 

   number = cardNotation[:1]

   color = cardNotation[1:]

   print cardNumberValues.get(number) + " of " + cardColors.get(color)

 

else:

   print "INVALID VALUE"

You might be interested in
What country is associated with the tor relay using the ip address 104. 244. 74. 97?.
Lelu [443]

Answer:

104.28.63.45 is an IP address located in Santos, Sao Paulo.

Explanation:

3 0
2 years ago
including how it can be stored and what types of operations we can perform. For example, we can write a program that squares num
ASHA 777 [7]

Answer:

The solution code is written in Python:

  1. def square(num):
  2.    if type(num).__name__ == 'int':
  3.        sq_num = num * num
  4.        return sq_num  
  5.    else:
  6.        return "Invalid input"
  7. print(square(5))
  8. print(square("Test"))

Explanation:

To ensure only certain type of operation can be applied on a input value, we can check the data type of the input value. For example, we define a function and name it as <em>square</em> which take one input number, <em>num </em>(Line 1).

Before the <em>num</em> can be squared, it goes through a validation mechanism in by setting an if condition (Line 2) to check if the data type of the input number is an integer,<em> int.</em> If so, the<em> num </em>will only be squared otherwise it return an error message (Line 6).

We can test our function by passing value of 5 and "Test" string. We will get program output:

25

Invalid input

6 0
3 years ago
To check for consciousness:
Lesechka [4]

The answer to your question is,

D) Check their pulse.

((Well, some people say to place your ear over the persons mouth and watch for a rise and fall of the chest-- but that's not an answer nor does that really go with any of the answers provided so..))


-Mabel <3

6 0
3 years ago
Read 2 more answers
True and false 1. Trace topology is also referred to as tree bus topology. ​
algol13

Answer:

Trace topology is also referred to as tree bus topology.

Explanation:

6 0
2 years ago
Drag the tiles to the correct boxes to complete the pairs.
Zepler [3.9K]

Answer:

the answer is to fail

Explanation:

4 0
3 years ago
Other questions:
  • If you want a user to enter exactly 20 values which loop would be the best to use
    12·1 answer
  • Which key must you press after you write into a cell?
    12·1 answer
  • Consider the following code: // Merge mailing list m2 into m1 void merge (MailingList m1, MailingList m2) { for (int i = 0; i &l
    12·1 answer
  • What are some examples of what can be changed through options available on the mini toolbar
    5·1 answer
  • State ONE (1) disadvantage of using computers to store and process<br> information.
    10·1 answer
  • Match the desired outcome to the appropriate action.
    6·1 answer
  • Which one of the patterns have the highest pitch?​
    14·2 answers
  • Would my phone still work if I snapped it in half?
    8·2 answers
  • Which of the following is an antivirus software?
    6·1 answer
  • A company is looking for an employee to design and test connections in its
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!