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
What happens it the offshore team members are not able to participate in the iteration demo due to time zone/infrastructure issu
professor190 [17]

The best option that will suite is that there will be no major issues since the offshore leads and the onsite members participated in the demo with the Product Owner/Stakeholders they can cascade the feedback to the offshore members

Explanation:

Iteration demo is the review which is done to gather the immediate feedback from the stakeholders on a regular basis from the regular cadence. This demo will be one mainly to review the progress of the team and the and to cascade and show their working process

They show their working process to the owners and they and the other stakeholders and they get their review from them and so there will be no issues if the members are not able to participate

5 0
3 years ago
Sonic the Hedgehog (1991)
e-lub [12.9K]

Answer:

What if we made a fast game?

Explanation:

The mascot is the person, animal or thing which brings good luck, just like Mario. However, this is not a problem with Sonic the Hedgehog. And the Hedgehog is powerful enough to cross any barrier. Hence tieing the collectibles is not required. And the Hedgehog is quite cute and domestic. But it moves only 10 meters per second if we are considering the maximum speed. Hence, the correct option is certainly what if we made a fast game? And this is option C.

7 0
3 years ago
Given four inputs: a, b, c &amp; d, where (a, b) represents a 2-bit unsigned binary number X; and (c, d) represents a 2-bit unsi
Amiraneli [1.4K]

Answer:

z = a.c' + a.b.d' + b.c'.d'

Explanation:

The truth table for this question is provided in the attachment to this question.

N.B - a' = not a!

The rows with output of 1 come from the following relations: 01 > 00, 10 > 00, 10 > 01, 11 > 00, 11 > 01, 11 > 10

This means that the Boolean expression is a sum of all the rows with output of 1.

z = a'bc'd' + ab'c'd' + ab'c'd + abc'd' + abc'd + abcd'

On simplification,

z = bc'd' + ab'c' + ac'd' + ac'd + abc' + abd'

z = ac' + abd' + bc'd'

Hope this helps!

6 0
3 years ago
Jim, the IT director, is able to complete IT management task very well but is usually two weeks late in submitting results compa
oee [108]

Answer:Effective but not efficient

Explanation:

Jim is effective because he was able to complete the IT tasks well but he is not efficient because he didn't submit the result on time because being efficient includes management of time.

5 0
3 years ago
IT ethics are rules, policies, or principles that guide the behavior of IT professionals.
Vadim26 [7]

Answer: true

Explanation: true

6 0
2 years ago
Other questions:
  • Olivia needs to get permission to use a graph of data gathered by a trade association she plans to include the graph in a report
    10·2 answers
  • For conditional formatting, a formula must be in the form of a(n) _____ test that results in a true or false value. Question 1 o
    8·1 answer
  • Troubleshooting a printer that does not work includes a. connecting the printer to your computer b. checking to see if there is
    13·1 answer
  • What is the name for the type of flash memory that is used by mobile devices to store their apps and data?
    6·1 answer
  • Which types of scenarios would the NETWORKDAYS function help calculate? Check all that apply.
    7·1 answer
  • python Write a program that will take a file named Celsius.dat that contains a list of temperatures in Celsius (one per line), a
    9·1 answer
  • Select the correct answer from each drop-down menu. Look at Marta's email signature and fill in the missing elements. Marta D'Ab
    14·2 answers
  • In c++ 11, the ________ tells the compiler to determine the variable's data type from the initialization value.
    6·1 answer
  • Powerful IT security systems are needed to defend against what appears to be authorized access to a network or application. Sele
    6·1 answer
  • To print a budget:________.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!