Python Code:
import random
n = 10 #for n=10
clist = []
cmap = {}
for sim in range(1,1001): #simulating 1000 times
A=[]
B=[]
C=[]
D=[]
E=[]
for i in range(1,n+1):#creating original lists A,D,E
A.append(i)
D.append(i)
E.append(i)
for j in range(n): #creating choice lists B,C
B.append(random.choice(D))
D.remove(B[j])
C.append(random.choice(E))
E.remove(C[j])
c=0 #to store fixed points
for k in range(n):
if B[k] == C[k]:
c = c+1
clist.append(c) #storing the fixed points in clist
for item in clist: #getting the count of each fixed point and
storing it in a map
if(item in cmap):
cmap[item] = cmap[item]+1
else:
cmap[item] = 1
sortedkeys = sorted(cmap.keys()) #soting the map
sortedmap = {}
for item in sortedkeys:
sortedmap[item] = cmap[item]
print(f'Deck of {n} cards...1000 different selections') #printing
the results
print('Fixed Pts\tPercentge\tQuantity')
index = 0
for item in sortedmap.keys():
size = sortedmap[item]
print(f'{item}\t\t{size/1000}\t\t{size}')
index+=1
n = 100 #this is for n=100
clist = []
cmap = {}
for sim in range(1,1001):
A=[]
B=[]
C=[]
D=[]
E=[]
for i in range(1,n+1):
A.append(i)
D.append(i)
E.append(i)
for j in range(n):
B.append(random.choice(D))
D.remove(B[j])
C.append(random.choice(E))
E.remove(C[j])
c=0
for k in range(n):
if B[k] == C[k]:
c = c+1
clist.append(c)
for item in clist:
if(item in cmap):
cmap[item] = cmap[item]+1
else:
cmap[item] = 1
sortedkeys = sorted(cmap.keys())
sortedmap = {}
for item in sortedkeys:
sortedmap[item] = cmap[item]
print(f'Deck of {n} cards...1000 different selections')
print('Fixed Pts\tPercentge\tQuantity')
index = 0
for item in sortedmap.keys():
size = sortedmap[item]
print(f'{item}\t\t{size/1000}\t\t{size}')
index+=1
n = 1000 #this is for n=1000
clist = []
cmap = {}
for sim in range(1,1001):
A=[]
B=[]
C=[]
D=[]
E=[]
for i in range(1,n+1):
A.append(i)
D.append(i)
E.append(i)
for j in range(n):
B.append(random.choice(D))
D.remove(B[j])
C.append(random.choice(E))
E.remove(C[j])
c=0
for k in range(n):
if B[k] == C[k]:
c = c+1
clist.append(c)
for item in clist:
if(item in cmap):
cmap[item] = cmap[item]+1
else:
cmap[item] = 1
sortedkeys = sorted(cmap.keys())
sortedmap = {}
for item in sortedkeys:
sortedmap[item] = cmap[item]
print(f'Deck of {n} cards...1000 different selections')
print('Fixed Pts\tPercentge\tQuantity')
index = 0
for item in sortedmap.keys():
size = sortedmap[item]
print(f'{item}\t\t{size/1000}\t\t{size}')
index+=1
n = 10000 #this is for n=10000
clist = []
cmap = {}
for sim in range(1,1001):
A=[]
B=[]
C=[]
D=[]
E=[]
for i in range(1,n+1):
A.append(i)
D.append(i)
E.append(i)
for j in range(n):
B.append(random.choice(D))
D.remove(B[j])
C.append(random.choice(E))
E.remove(C[j])
c=0
for k in range(n):
if B[k] == C[k]:
c = c+1
clist.append(c)
for item in clist:
if(item in cmap):
cmap[item] = cmap[item]+1
else:
cmap[item] = 1
sortedkeys = sorted(cmap.keys())
sortedmap = {}
for item in sortedkeys:
sortedmap[item] = cmap[item]
print(f'Deck of {n} cards...1000 different selections')
print('Fixed Pts\tPercentge\tQuantity')
index = 0
for item in sortedmap.keys():
size = sortedmap[item]
print(f'{item}\t\t{size/1000}\t\t{size}')
index+=1
(Change the n value for different blocks code is exactly the same)
Sample Output:
We notice that results get more accurate as we increase the n size
given code: assignment: use python to extend the given code to create an output similar to...
Card Game Simulation(in Python 3.8.1) The purpose of this assignment is to help you gain experience using while loops to solve problems. For this assignment, you will simulate a simplified card game that has some similarity to the game of 21. At the start of the program, the user will be asked to supply both the winning score (an integer from 1 thru 21) and the number of times to run the simulation (an integer from 100 to 100,000). To...
Hi! I need help with a C++ program In this assignment, you will create some routines that will later be used in a "Black Jack" program. Your output on this first part will look something like: card's name is QC with a black jack value of 10 Unshuffled Deck AC/1 2C/2 3C/3 4C/4 5C/5 6C/6 7C/7 8C/8 9C/9 TC/10 JC/10 QC/10 KC/10 AD/1 2D/2 3D/3 4D/4 5D/5 6D/6 7D/7 8D/8 9D/9 TD/10 JD/10 QD/10 KD/10 AH/1 2H/2 3H/3 4H/4 5H/5...
Complete a program In C#: some code is included, you edit the areas that have not been filled. For your C# program you will complete code that plays the War card game. In this game, the deck of cards is evenly divided among two players. The players are not allowed to look at the cards in their hand. On each round of the game, both players lay down the top card from their hand. The player with the higher value...
urgent help with python. can somone code this please and show output QUESTION: There are a variety of games possible with a deck of cards. A deck of cards has four different suits, i.e. spades (*), clubs (*), diamonds (), hearts (), and thirteen values for each suit. Now write a function that uses list comprehension to create a deck of cards. Each element in the list will be a card, which is represented by a list containing the suit...
C Programming The following code creates a deck of cards, shuffles it, and deals to players. This program receives command line input [1-13] for number of players and command line input [1-13] for number of cards. Please modify this code to deal cards in a poker game. Command line input must accept [2-10] players and [5] cards only per player. Please validate input. Then, display the sorted hands, and then display the sorted hands - labeling each hand with its...
Create a complete pseudo-code program in C++ to do the following using the PseudoCode language developed in class using Absolute Addressing. There is 1 deliverable: 1. You should include the input cards shown below as a test. THE PROGRAM: First you will read in a value N which holds the number of values to be read in. (so if N is 20 then there will be 20 more cards to read in.) Read in N values into an array. Bubble-Sort...
IN PYHTON CODE Question #3 Produce a function prime_factors.dict that has one integer variable n that is assumed to be greater than 1. The function will return a dictionary with keys the integers from 2 to n, inclusive, and with values the set of prime factors of each key. So, the command prime_factors.dict (8) will return the dictionary 2 123,3: 3),4 2),5 (53,6 2,3),7:7),8 {2)) Note that even though the prime number 2 appears twice in the prime fac- torization...
use Python IDEL Problem 4 Fix a program. This program should calculate the matrix addition (C - A+B, where each element of matrix C is equal to the sum of the elements of matrices A and B that have the same indexes cij - aij + bij). However it is incomplete: the range() function arguments, index values of nested lists A, B, and C, and two list statements are missing. Can you find them and fix the program? What is...
How do I start this c++ code homework? Write a code in C++ for a BlackJack card game using the following simplified rules: Each card has a numerical value. Numbered cards are counted at their face value (two counts as 2 points, three, 3 points, and so on) An Ace count as either 1 point or 11 points (whichever suits the player best) Jack, queen and king count 10 points each The player will compete against the computer which represents...
I was asked this question:Given any input series a corresponding graph must be generated without the use of any libraries.After, trying my best, I arrived at this solution to which they replied it had a logical issue.# Create the matrix print("Enter the sequence with spaces: ") arr = list(map(int, input().split())) count = len(arr) rows = int(sum(arr)) cols = int(sum(arr) + 4) content = [[" "]*cols for _ in range(rows)] maxq = 0 maxp = 0 content[0][0] = "/" # Apply the positions in the matrix p = 0 q = arr[0] k = 0 for l in range(q): if (k != q): content[k][p] = "/" p = p + 1 k = k + 1 p = q flag = 1 i = 0 j = 0 k = 0 c = 0 temp = 0 r = 0 flag = 1 for i,j in enumerate(arr): c = c + 1 if c < count: k = arr[i+1] else: k = 0 if arr[i]: if flag == 1: content[q][p] = "/\\" if maxq < q: maxq = q maxp = p qori = q pori = p p = p + k temp = q - k...