Il giorno martedì 12 dicembre 2017 00:30:24 UTC+1, jlad...@itu.edu ha scritto:
> On Thursday, December 7, 2017 at 4:49:52 AM UTC-8, edmondo.g...@gmail.com
> wrote:
>
> > import numpy
>
> I teach Python to students at varying levels. As much as I love and use
> Numpy in my regular work, I try
On Thursday, December 14, 2017 at 7:02:56 PM UTC+5:30, Rustom Mody wrote:
> On Thursday, December 14, 2017 at 3:53:21 PM UTC+5:30, Lorenzo Sutton wrote:
> > Hi Roger,
> >
> > On 13/12/17 23:31, ROGER GRAYDON CHRISTMAN wrote:
> > > On Wed, Dec 13, 2017, Lorenzo Sutton wrote:
> > >>
> > > On 05/12/1
On Thursday, December 14, 2017 at 3:53:21 PM UTC+5:30, Lorenzo Sutton wrote:
> Hi Roger,
>
> On 13/12/17 23:31, ROGER GRAYDON CHRISTMAN wrote:
> > On Wed, Dec 13, 2017, Lorenzo Sutton wrote:
> >>
> > On 05/12/17 06:33, nick martinez2 via Python-list wrote:
> >>> I have a question on my homework.
On 14/12/17 10:22, Lorenzo Sutton wrote:
Hi Roger,
On 13/12/17 23:31, ROGER GRAYDON CHRISTMAN wrote:
On Wed, Dec 13, 2017, Lorenzo Sutton wrote:
On 05/12/17 06:33, nick martinez2 via Python-list wrote:
I have a question on my homework.
[...]
For this kind of problem I think the collection
Hi Roger,
On 13/12/17 23:31, ROGER GRAYDON CHRISTMAN wrote:
On Wed, Dec 13, 2017, Lorenzo Sutton wrote:
On 05/12/17 06:33, nick martinez2 via Python-list wrote:
I have a question on my homework.
[...]
For this kind of problem I think the collections module [1] can be very
useful. In this c
On Thursday, December 7, 2017 at 7:11:18 AM UTC-8, Rhodri James wrote:
> Sigh. Please don't do people's homework for them. It doesn't teach
> them anything. Now Nick had got 90% of the way there and shown his
> working, which is truly excellent, but what he needed was for someone to
> hint a
On 12/13/2017 8:28 AM, bo...@choices.random.py wrote:
nick.martin...@aol.com (nick martinez2) writes:
def rollDie(number):
rolls = [0] * 6
for i in range(0, number):
roll=int(random.randint(1,6))
One could just as well use randint(0, 5) and skip the -1 below.
rol
On Wed, Dec 13, 2017, Lorenzo Sutton wrote:
>
On 05/12/17 06:33, nick martinez2 via Python-list wrote:
>> I have a question on my homework. My homework is to write a program in
>which
>> the computer simulates the rolling of a die 50 times and then prints
>> (i). the most frequent side of the die (
On Thu, Dec 14, 2017 at 3:23 AM, wrote:
> from random import randint
>
> rolls = [randint(1, 6) for x in range(50)]
> print("Average: %s" % (sum(rolls) / len(rolls)))
> print("Most Common: %s" % max(rolls, key=rolls.count))
Great demo of a bad algorithm. :)
ChrisA
--
https://mail.python.org/ma
from random import randint
rolls = [randint(1, 6) for x in range(50)]
print("Average: %s" % (sum(rolls) / len(rolls)))
print("Most Common: %s" % max(rolls, key=rolls.count))
--
https://mail.python.org/mailman/listinfo/python-list
nick.martin...@aol.com (nick martinez2) writes:
> def rollDie(number):
> rolls = [0] * 6
> for i in range(0, number):
> roll=int(random.randint(1,6))
> rolls[roll - 1] += 1
> return rolls
def rollDie(number):
from random import choices
return choices((1,2,3,4,5
Hi,
On 05/12/17 06:33, nick martinez2 via Python-list wrote:
I have a question on my homework. My homework is to write a program in which
the computer simulates the rolling of a die 50 times and then prints
(i). the most frequent side of the die (ii). the average die value of all
rolls.
For t
On Thursday, December 7, 2017 at 4:49:52 AM UTC-8, edmondo.g...@gmail.com wrote:
> import numpy
I teach Python to students at varying levels. As much as I love and use Numpy
in my regular work, I try to avoid showing beginning Python students solutions
that require third-party packages. Her
On Tue, Dec 05, 2017 at 09:02:54PM +1200, ssghotra1997 wrote:
> for i in range(num):
> rolls = int(random.randint(1, 6))
> if rolls == 1:
> sides['One'] += 1
[...]
Using integers as the key makes the code a bit shorter... That
approach is also better if you're usin
import random
def rollDie(num):
sides = {'One':0, 'Two':0,'Three':0,'Four':0,'Five':0,'Six':0}
for i in range(num):
rolls = int(random.randint(1, 6))
if rolls == 1:
sides['One'] += 1
if rolls == 2:
sides['Two'] += 1
if rolls == 3:
On 2017-12-06 01:33, nick.martinez2--- via Python-list wrote:
> I have a question on my homework. My homework is to write a program in which
the computer simulates the rolling of a die 50
> times and then prints
> (i). the most frequent side of the die
> (ii). the average die value of all rolls.
>
On 07/12/17 13:19, Mario R. Osorio wrote:
On Tuesday, December 5, 2017 at 8:33:52 PM UTC-5, nick martinez wrote:
I have a question on my homework.
[snip]
Just my 2 cents:
Sigh. Please don't do people's homework for them. It doesn't teach
them anything. Now Nick had got 90% of the way
On Tuesday, December 5, 2017 at 8:33:52 PM UTC-5, nick martinez wrote:
> I have a question on my homework. My homework is to write a program in which
> the computer simulates the rolling of a die 50
> times and then prints
> (i). the most frequent side of the die
> (ii). the average die value o
Il giorno mercoledì 6 dicembre 2017 02:33:52 UTC+1, nick martinez ha scritto:
> I have a question on my homework. My homework is to write a program in which
> the computer simulates the rolling of a die 50
> times and then prints
> (i). the most frequent side of the die
> (ii). the average die val
On Wednesday, December 6, 2017 at 9:28:26 PM UTC+11, D'Arcy Cain wrote:
> On 12/05/2017 07:33 PM, nick.martinez2--- via Python-list wrote:
> > I have a question on my homework. My homework is to write a program in
> > which the computer simulates the rolling of a die 50
> > times and then prints
>
I think carelessness in choosing variable names may be at the root of
the problem.
nick.martin...@aol.com wrote:
I have a question on my homework. My homework is to write a program in which
the computer simulates the rolling of a die 50
times and then prints
(i). the most frequent side of the
On 12/05/2017 07:33 PM, nick.martinez2--- via Python-list wrote:
I have a question on my homework. My homework is to write a program in which
the computer simulates the rolling of a die 50
times and then prints
(i). the most frequent side of the die
(ii). the average die value of all rolls.
I wr
import random
def rollDie(num):
sides = {'One':0, 'Two':0,'Three':0,'Four':0,'Five':0,'Six':0}
for i in range(num):
rolls = int(random.randint(1, 6))
if rolls == 1:
sides['One'] += 1
if rolls == 2:
sides['Two'] += 1
if rolls == 3:
On 2017-12-06 01:33, nick.martinez2--- via Python-list wrote:
I have a question on my homework. My homework is to write a program in which
the computer simulates the rolling of a die 50
times and then prints
(i). the most frequent side of the die
(ii). the average die value of all rolls.
I wrote
24 matches
Mail list logo