Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By Fubarable

Thread: Python to Java Partyguest

  1. #1
    scotty is offline Member
    Join Date
    Jun 2013
    Rep Power

    Default Python to Java Partyguest

    Hi I would like to converte that Python Code to Java Coud someone help me with a converting and a few comments:

    You are at a party with n people. One party guests start a rumor about another party guest.
    Every person who hears the rumor tells a it to another person and avoids to tell the person person from whom the speech is. If someone already knew the rumor, and this gets retold, this person does not spread the rumor further.
    The simulation should repeated and calculate 100,000 times and how many people on average learn the rumor.

    Thanks all so I have to change the guest to n people not 51

    import random
    guests = 51

    def simulation():
    Gaeste=[False for x in range(0,guests)]
    Sum = 0


    listeners = random.randint(0,guests-1)
    if Gaeste[listeners]==False:
    Gaeste[Zuhoerer] = True
    else: break

    for x in range(guests-1):
    if Gaeste[x]:
    Sum += 1
    return Sum

    Summe = 0
    for x in range (100000):
    average = Summe/100000


  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power

    Default Re: Python to Java Partyguest

    This is not a site where you ask others to convert code for you. Please feel free to try to code this yourself, and if you run into problems, ask a specific question and we'll be more than happy to help.
    DarrylBurke likes this.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power

    Default Re: Python to Java Partyguest

    Funny, Python lives or dies with (in)correct line indentation and the lack of code tags ruins the entire post ...

    kind regards,

    Build a wall around Donald Trump; I'll pay for it.

Similar Threads

  1. Java vs. Python
    By bob 6 in forum Forum Lobby
    Replies: 3
    Last Post: 09-10-2012, 12:37 PM
  2. Passing arguments from java to python
    By wavefunction in forum Advanced Java
    Replies: 4
    Last Post: 07-10-2011, 05:36 PM
  3. Running a Python Script in Java
    By JavaN00bie in forum New To Java
    Replies: 6
    Last Post: 06-22-2011, 10:23 PM
  4. calling python file from java
    By cool in forum AWT / Swing
    Replies: 3
    Last Post: 11-11-2010, 04:50 AM
  5. Jython : python for java
    By cotarelo in forum New To Java
    Replies: 1
    Last Post: 03-25-2010, 09:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts