Chat with us, powered by LiveChat When the code is complete it should run with the code I provided…do NOT alter my completed functions, just add in the function that will make the code work. (Add code where it says TO Do: Only few lines code needed) | Abc Paper
+1(978)310-4246 credencewriters@gmail.com
Select Page

1. Complete TempConversion.py —
(6pYou need to add in the convertToCelsius function and the convertToFahren function.
You also need to complete the body of the functions. The conversion methods should use
the math formula included in the comments.code:def main(): if isCelsius(): celsius = float(input(“Enter the degrees(Celsius): “)) fahren = convertToFahren(celsius) print(celsius,”degrees in Celsius is”,fahren,”degrees in Fahrenheit”) else: fahren = float(input(“Enter the degrees(Fahrenheit): “)) celsius = convertToCelsius(fahren) print(fahren,”degrees in Fahrenheit is”,celsius,”degrees in Celsius”) def isCelsius(): “”” A method that prompts the user whether or not they would like to convert celsius to fahrenheit. :return true if the user said they wanted celsius, false otherwise “”” choice = input(“Do you want to convert to Celsius (C) or Fahrenheit (F)”).upper() while choice!=’C’ and choice!=’F’: choice = input(“Do you want to convert to Celsius (C) or Fahrenheit (F)”).upper() return choice==’C’## TODO: write the code for convertToCelsius, using the formula: c = 5.0/9.0*(f-32)## TODO: write the code for convertToFahren, using the formula: f = 9.0/5.0*c + 32main()2. Complete the requirements noted in BlackJack.py —
You need to add in the computeHandScore function that uses the two cards from
either hand and computes the score. Assume and Ace is 11 points**, King, Queen, and Jack
are 10, and the number cards are their value.
**The Ace will be scored as an eleven if and only if they do not have both elevens, count one
of them as value in this case, prevent busting in this simplified versioncode: import randomdef main(): playCard1=dealCard([]) #no cards drawn yet houseCard1=dealCard([playCard1]) playCard2=dealCard([playCard1,houseCard1]) houseCard2=dealCard([playCard1,houseCard1,playCard2]) print(“Player’s Hand: “+playCard1+”, “+playCard2) playScore = computeHandScore(playCard1, playCard2) print(“The player has ” + playScore + ” points”) print(“House’s Hand: “+houseCard1+”, “+houseCard2) houseScore = computeHandScore(houseCard1, houseCard2) print(“The player has ” + houseScore + ” points”)#TODO: Add in the computeHandScore function, so that it will compute the value given the two cards passed.def dealCard(dealtCardList): “”” Randomly selects a new card out of 52 possibilties, if the card is already chosen (c1-c4) then another random card is chosen (repeating until a card drawn hasn’t been seen) :param dealtCardList a list containing strings representing the card face (A,K,Q,J,10,9…) followed by a suit (H,D,S,C) that were already dealt :return the String representation of the card (value followed by suit), examples: 2H (2 of hearts), KS (King of Spades),…etc “”” cardN = random.randrange(0,52) cardFace = convertNumToCard(cardN) # Returns 2H or AD for example while cardFace in dealtCardList: # Card already dealt…need a new one cardN = random.randrange(0,52) cardFace = convertNumToCard(cardN) # Returns 2H or AD for example return(cardFace) def convertNumToCard(card): “”” Converts a numberic value (0-51) into a String representation: FaceValue followed by the Suit, examples: 2H (2 of hearts), KS (King of Spades),…etc :param card a numeric representation of the card 0-51 (52 cards in a deck) :return the String representation of the card (value followed by suit), examples: 2H (2 of hearts), KS (King of Spades),…etc “”” suitV = card//13 cardV = card%13+2 cardFace=”” if cardV<11: cardFace+=str(cardV) # 2-10 elif cardV==11: cardFace+="J" elif cardV==12: cardFace+="Q" elif cardV==13: cardFace+="K" elif cardV==14: cardFace+="A" if suitV==0: cardFace+="H" # hearts if suitV==1: cardFace+="C" # clubs if suitV==2: cardFace+="D" # diamonds if suitV==3: cardFace+="S" # spades return(cardFace)main()

error: Content is protected !!