Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Python, Check this code: # # Here we import the random module. import random #_______________________________ # Here we define the two lists needed using

In Python,

Check this code:

#

# Here we import the random module.

import random #_______________________________

# Here we define the two lists needed using the split() method.

suits = "Clubs Diamonds Hearts Spades".split()

values = "Ace Two Three Four Five Six Seven Eight Nine Ten Jack Queen King".split()

#______________________________ # This function generates a random card

def randomCard():

return values[random.randint(0,12)] + " of " + suits[random.randint(0,3)]

#_______________________________

# 'hand' gets 5 random cards. and 'card' gets a random card.

hand = []

for i in range(5):

hand.append(randomCard())

card=randomCard()

#_______________________________

# The function GoFishFor() checks to see:

#1 * If 'card' is in 'hand': we remove it from 'hand' and return both in a list.

# 2* If 'card' is not in 'hand': we return the string 'Go Fish'.

def GoFishFor(card,hand): for c in hand:

if card == c:

hand.remove(card)

return [card, hand]

return 'Go Fish'

#________________________________________________________________________________

Write a functions 'GoFishIn(card, hand)' to replace the GoFishFor(card, hand) function.

The only difference between the two functions you're being asked to 'remove the for loop' and use the 'in

operator'

Only write the GoFishIn() function.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Databases Concepts And Practice

Authors: Suzanne W Dietrich

1st Edition

1119827949, 9781119827948

More Books

Students also viewed these Databases questions

Question

How does this compare with the Fog Index for your written message?

Answered: 1 week ago

Question

=+What is the nature of the unions in the particular country?

Answered: 1 week ago