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
adelina 88 [10]
3 years ago
15

The birthday problem is as follows: given a group of n people in a room, what is the probability that two or more of them have t

he same birthday? It is possible to determine the answer to this question via simulation. Using the starting template provided to you, complete the function called calc birthday probability that takes as input n and returns the probability that two or more of the n people will have the same birthday. To do this, the function should create a list of size n and generate n birthdays in the range 1 to 365 randomly, inclusive of the end-points 1 and 365. It should then check to see if any of the n birthdays are identical. The function should perform this experiment 106 times and calculate the fraction of time during which two or more people had the same birthday. The function will be called as follows from your main program
Import random

def calc_birthday_probability (num_people):
num_tries = le6
num_duplicates = 0

""" FIXME: Complete this function to return the probability of num_people in the room having the same birthday. """

return num_duplicates/num_tries
def main ():
num_people = 10
p = calc_birthday_probability (num_people)

num_people = 20
p = calc_birthday_probability (num_people)

return

# Main program
if __name__ == "_main_":
random.seed (2020)
main ()
Computers and Technology
1 answer:
Julli [10]3 years ago
4 0

Answer:

import random

def calc_birthday_probability(num_people):

   num_tries = 1e6

   num_duplicates = 0

   tries = 0

   while tries < num_tries:

       total_birthday = {}

       for i in range(1, 366):

           total_birthday[i] = 0

       for count in range(num_people):

           birthday = random.randint(1, 365)

           if total_birthday[birthday] != 0:

               num_duplicates += 1

               break

           total_birthday[birthday] += 1

       tries += 1

   return num_duplicates/num_tries

def main():

   num_people = 10

   p = calc_birthday_probability (num_people)

   print(p)

   num_people = 20

   p = calc_birthday_probability (num_people)

   print(p)

   return

if __name__ == "__main__":

   random.seed(2020)

   main()

Explanation:

  • Run the loop until the value of tries is less than num_tries to do number of trials.
  • Run the loop to create the desired number of birthdays by generating random numbers.
  • Increase  the num_duplicates  variable by 1, if the birthday has  already occurred.
  • Lastly define and then call the main function.

You might be interested in
A working model of a new product for testing purposes.
kotykmax [81]
Prototype is a working model for a product only for  testing purposes
6 0
2 years ago
Your program has a two-dimensional array, scores. You are implementing your array with lists. Each member in the array is a pair
Viefleur [7K]

Answer:

scores.append(6,2)

Explanation:

This is a complicated question because in theory, scores.insert can also add values, but I am sure that the only line of code that would work is scores.append(6,2)

7 0
2 years ago
Which securities protect data through processes, procedures,decisions,and user pernissions. Determines where and how data can be
vovangra [49]

Answer:

Data can be stored on storage devices.

Explanation:

Network security, Application security and information security are the securities that protect data. Data can be stored on storage devices such as hard disk drives, solid state drives, external hard drives, USB flash drives and SD cards etc. Hard disk drives, floppy disks and tapes store data magnetically. The data can be stored with a device that spins the disk with magnetic coatings and heads has the ability to read and write information in the form of magnetic patterns.

5 0
3 years ago
Public static void prefixmerge(customer[] list1, customer[] list2, customer[] result {
White raven [17]
I can't get what do you need, but I guess it's a part of java code. I can explain what it means. It's used to unite two rising sorted arrays which are list1 and list2. The result is stored in result array. I suggest you to clearly explain your task as it's difficult to give you correct answer.
8 0
3 years ago
Three broad categories of cryptographic algorithms are commonly used to create PRNGs: symmetric block ciphers, asymmetric cipher
RideAnS [48]

Answer:

True.

Explanation:

In generating PRNGs, several specific types of crypto algorithms will be widely will use: linear cipher block, nonlinear ciphers, as well as hash methods and authorization instructions in messages. So, that's why the following scenario is true about the cryptographic algorithms because this is a collection of several excellently defined however complicated mathematics techniques for encoding or decoding information.

7 0
3 years ago
Other questions:
  • To find a webpage, the user of a search engine would simply enter a word or phrase in the resource's text box. what is the term
    11·1 answer
  • Which of the following are you likely to find between multiple school buildings in a city wide school district?
    9·1 answer
  • To access WordPad, Jill will click on Start, All Programs, Accessories, and WordPad. To access Notepad, Karl will click on Start
    11·1 answer
  • Laura has identified the job she wants, the skills needed for the position, and the areas she needs to improve in order to get i
    10·1 answer
  • If you want to prioritize downloads of your mobile app instead of visits to your mobile site, you should: a) add a sitelink exte
    10·1 answer
  • Please answer this I know that no one else does but I can't think right now
    10·1 answer
  • A(n) monitoring vulnerability scanner is one that listens in on the network and determines vulnerable versions of both server an
    7·1 answer
  • A franchise restaurant is attempting to understand if customers think their service is good day-to-day by summarizing a series o
    10·1 answer
  • What is said to be the first mechanical calculator​
    7·2 answers
  • Compare and discuss between electromechanical and electronic era of computer​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!