I have to write a program where the program prints a deck of cards. instead of having your regular suits and numbers the program will use a value for a number, id will be either rock, paper, or scissors, and the coin will be heads or tails. print example: 2 of rock heads. If the user is enters 1 the program will print out 30 of the print example and arrange them by there values. if the user enters 2 it will print out 30 of the print statements and arrange them by there id. I need to use a selection sort. how would I code this.



from deck import Deck
def main():
deck = Deck()
while True:
hand = []
print("")
print("New Hand")
print("")
print("1) Sort by value")
print("2) Sort by id")
print("3) Find card")
print("4) New Hand")
print("5) Quit")
menu = eval(input("Make a selection : "))
if menu == 1: # sort by card value
for i in range(30):
hand.append(deck.draw())
print(hand)
for i in range(len(hand)-1):
min = i
for j in range(i,len(hand)):
if hand[j].getCardValue() < hand[min].getCardValue():
min = j
if min != i:
hand[i],hand[min] = hand[min],hand[i]
print('Sorted by Value: ')
print(hand)
elif menu == 2: # sort by card id
for i in range(30):
hand.append(deck.draw())
print(hand)
for i in range(len(hand)-1):
min = i
for j in range(i,len(hand)):
if hand[j].getHand() < hand[min].getHand():
min = j
if min != i:
hand[i],hand[min] = hand[min],hand[i]
print('Sorted by Id: ')
print(hand)
elif menu == 3:
search = eval(input('Enter a value to search for : '))
if search <= 52:
print("1) Rock")
print("2) Paper")
print("3) Scissors")
hand = eval(input("Enter a hand : "))
if hand <= 4:
print("1) Heads")
print("2) Tails")
coin = eval(input("Choose a coin : "))
elif menu == 4:
main()
elif menu == 5:
print("Thanks for playing")
break
main()
#end of program
Code Screenshot:


Output:

I have to write a program where the program prints a deck of cards. instead of having your regula...
I am having trouble with my Python code in this dictionary and
pickle program. Here is my code but it is not running as i am
receiving synthax error on the second line.
class Student:
def__init__(self,id,name,midterm,final):
self.id=id
self.name=name
self.midterm=midterm
self.final=final
def calculate_grade(self):
self.avg=(self.midterm+self.final)/2
if self.avg>=60 and self.avg<=80:
self.g='A'
elif self.avg>80 and self.avg<=100:
self.g='A+'
elif self.avg<60 and self.avg>=40:
self.g='B'
else:
self.g='C'
def getdata(self):
return self.id,self.name.self.midterm,self.final,self.g
CIT101 = {}
CIT101["123"] = Student("123", "smith, john", 78, 86)
CIT101["124"] = Student("124", "tom, alter", 50,...
For my computer class I have to create a program that deals with
making and searching tweets. I am done with the program but keep
getting the error below when I try the first option in the shell.
Can someone please explain this error and show me how to fix it in
my code below? Thanks!
twitter.py - C:/Users/Owner/AppData/Local/Programs/Python/Python38/twitter.py (3.8.3) File Edit Format Run Options Window Help import pickle as pk from Tweet import Tweet import os def show menu():...
I am currently facing a problem with my python program which i have pasted below where i have to design and implement python classes and record zoo database and takes user input as query. the error i am recieving says that in line 61 list index is out of range. kindly someone help me with it as soon as possible. Below is the program kindly check and correct it. Thanks! class Animal: def __init__(self, name, types, species, mass): self.name=name self.type=types...
Write a program in python that lets the user play the game Rock, Paper, Scissors against the computer. The program should work as follows: When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. 2 corresponds to paper, and 3 corresponds to scissors. To set up the random number library, write the following at the top of your code: import random random.seed(300) Use...
I am currently facing a problem with my python program which i have pasted below where i have to design and implement python classes and record zoo database and takes user input as query. the error i am recieving says that in line 61 list index is out of range. kindly someone help me with it as soon as possible. Below is the program kindly check and correct it. Thanks! class Animal: def __init__(self, name, types, species, mass): self.name=name self.type=types...
PYTHON. Continues off another code. I don't understand this. Someone please help! Comment the lines please so I can understand LinkedList ADT: class myLinkedList: def __init__(self): self.__head = None self.__tail = None self.__size = 0 def insert(self, i, data): if self.isEmpty(): self.__head = listNode(data) self.__tail = self.__head elif i <= 0: self.__head = listNode(data, self.__head) elif i >= self.__size: self.__tail.setNext(listNode(data)) self.__tail = self.__tail.getNext() else: current = self.__getIthNode(i - 1) current.setNext(listNode(data,...
The class "Deck" is defined for the initial deck of 52 cards. A simple list is used to store 52 poker cards. Consider the Deck class given as below: class Deck: def __init__(self, full=True): self.cards = [] cardlist = ['AS', 'AH', 'AC', 'AD', '2S', '2H', '2C', '2D', '3S', '3H', '3C', '3D', '4S', '4H', '4C', '4D', '5S', '5H', '5C', '5D', '6S', '6H', '6C', '6D', '7S', '7H','7C', '7D', '8S', '8H', '8C', '8D', '9S', '9H', '9C', '9D', 'TS', 'TH', 'TC', 'TD', 'JS', 'JH',...
PYTHON. Continues off another code(other code is below). I don't understand this. Someone please help! Comment the lines please so I can understand. There are short and med files lengths for each the list of names/ids and then search id file. These are the input files: https://codeshare.io/aVQd46 https://codeshare.io/5M3XnR https://codeshare.io/2W684E https://codeshare.io/5RJwZ4 LinkedList ADT to store student records(code is below). Using LinkedList ADT instead of the Python List. You will need to use the Student ADT(code is below) Imports the Student class...
I want to have a code that can pick whichever two planets in the
solar system and find the distance of them no matter where in their
orbit they are, but I keep getting errors. Can someone please help
me fix it?
f rom scipy import exp, pi, absolute, linspace import matplotlib. Ryplot as plt planet-I input ('Which planet do you want to pick for planet 1?") planet_2 input ('which planet do you want to pick for planet 27') distance...