On 2020-03-16 21:49, Grant Edwards wrote:
On 2020-03-16, Irv Kalb wrote:
I like both suggestions, and will probably go with the non-breaking
space (Option space on my Mac). I tested that and it works well.
Until somebody tries to cut/paste the snippets you post into a .py
file and run them.
On 17/03/20 10:49 AM, Grant Edwards wrote:
On 2020-03-16, Irv Kalb wrote:
I like both suggestions, and will probably go with the non-breaking
space (Option space on my Mac). I tested that and it works well.
Until somebody tries to cut/paste the snippets you post into a .py
file and run them
On 2020-03-16, Irv Kalb wrote:
> I like both suggestions, and will probably go with the non-breaking
> space (Option space on my Mac). I tested that and it works well.
Until somebody tries to cut/paste the snippets you post into a .py
file and run them. At that point the "distance learning" se
> On Mar 16, 2020, at 11:31 AM, Irv Kalb wrote:
>
> This is for anyone who teaches Python and uses the Canvas Learning Management
> System (maybe a small group).
>
> I teach Python at two colleges in Silicon Valley in California. At both
> schools we use Canvas. Overall, it works very well.
On 03/16/2020 11:31 AM, Irv Kalb wrote:
The problem is that in the feedback section for homework assignments, Canvas
eliminates any leading space characters. So, I might write:
if x == y:
# do thing 1
else:
# do thing 2
but when it gets posted and viewed by the student, it shows up
On 2020-03-16 18:31, Irv Kalb wrote:
This is for anyone who teaches Python and uses the Canvas Learning Management
System (maybe a small group).
I teach Python at two colleges in Silicon Valley in California. At both
schools we use Canvas. Overall, it works very well. I use it to post notes
This is for anyone who teaches Python and uses the Canvas Learning Management
System (maybe a small group).
I teach Python at two colleges in Silicon Valley in California. At both
schools we use Canvas. Overall, it works very well. I use it to post notes,
sample programs, build tests, post h
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
f the responses
> > > I see did attempt to work within the perceived constraints
> > > regarding what language tools the student was expected to use.
> >
> > I see your point as a teacher, but after all this *is* a Python mailing
> > list and not a python-homewo
articular student did post his intended solution,
> > instead of outright begging for code. And most of the responses
> > I see did attempt to work within the perceived constraints
> > regarding what language tools the student was expected to use.
>
> I see your point as a
expected to use.
I see your point as a teacher, but after all this *is* a Python mailing
list and not a python-homework-support mailing list.
That implies you shouldn't have answered a homework assignment at all :-p
--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list
teacher, but after all this *is* a Python mailing
list and not a python-homework-support mailing list.
Plus, the OP had already received various good answers specifically
helping them solve the problem along the lines of his proposed code, so
I guessed hinting to a standard library module
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.
>
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 the program so it says the most frequent number out of all the
r
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
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 the program so it says the most frequent number out of all the
On 02/02/2014 05:12 PM, David Hutto wrote:
A little OT, but these might peak your interest for this:
Also a little OT, but the word you're looking for is spelled pique. ;-)
(Although, it IS pronounced 'peak'.)
-=- Larry -=-
--
https://mail.python.org/mailman/listinfo/python-list
On Saturday, February 1, 2014 2:32:22 PM UTC-5, Denis McMahon wrote:
> On Fri, 31 Jan 2014 18:14:31 -0700, Scott W Dunning wrote:
>
>
>
> > little different from a few things you guys had mentioned. For one, I
>
> > got the correct time by calculating the number of time run and
>
> > converti
Should have been the following, which just shows the books price as a float as
well, but you get the point by now, I'm sure:
import random as r
def
order_total(price_per_book,percent_discount_amount,quantity,first_book_shipping,extra_book_shipping):
percent_discount = price_per_book * pe
Or a better iterating example for a database of shipping, or ordering books
would be:
import random as r
def
order_total(price_per_book,percent_discount_amount,quantity,first_book_shipping,extra_book_shipping):
percent_discount = price_per_book * percent_discount_amount
amount_o
On Sunday, February 2, 2014 12:43:01 PM UTC-5, Denis McMahon wrote:
> On Sun, 02 Feb 2014 08:57:03 -0800, David Hutto wrote:
>
>
>
> > Revised:
>
>
>
> > discounted_price = price_per_book - (price_per_book * percent_discount)
>
>
>
> by applying some simple algebra to the right hand side
>
On Sun, 02 Feb 2014 08:57:03 -0800, David Hutto wrote:
> Revised:
> discounted_price = price_per_book - (price_per_book * percent_discount)
by applying some simple algebra to the right hand side
price_per_book - (price_per_book * percent_discount)
"x = (x * 1)" so "price_per_book == (price_per
On Sat, 01 Feb 2014 05:18:34 -, Scott W Dunning
wrote:
Any chance you guys could help with another question I have? Below is a
code to a different problem. The only thing I don’t understand is why
when calculating the 'discounted price’ you have to subtract 1? Thanks
again guys!
On Sunday, February 2, 2014 11:38:57 AM UTC-5, MRAB wrote:
> On 2014-02-02 16:11, David Hutto wrote:
>
> > price_per_book = 24.95
>
> > discount = .40
>
> > quantity = 60
>
> >
>
> The original problem says:
>
>
>
> Suppose the cover price of a book is $24.95, but bookstores get a 40%
>
>
On Sunday, February 2, 2014 11:11:07 AM UTC-5, David Hutto wrote:
> price_per_book = 24.95
>
> discount = .40
>
> quantity = 60
>
>
>
> Here:
>
> discounted_price = (1-discount) * price_per_book
>
>
>
> The discounted price should be price_per_book - discount
>
>
>
> shipping = 3.0 + (6
On 2014-02-02 16:11, David Hutto wrote:
price_per_book = 24.95
discount = .40
quantity = 60
The original problem says:
Suppose the cover price of a book is $24.95, but bookstores get a 40%
discount. Shipping costs $3 for the first copy and 75 cents for each
additional copy. What is the total
price_per_book = 24.95
discount = .40
quantity = 60
Here:
discounted_price = (1-discount) * price_per_book
The discounted price should be price_per_book - discount
shipping = 3.0 + (60 - 1) * .75
shipping should be, I think, should be 3.0 + (quantity * .75)
total_price = 60 * discounted_price
Yeah you’re right I didn’t even notice that. For some reason I just added the
60 instead of using quantity which had been defined.
On Feb 1, 2014, at 8:50 AM, Dennis Lee Bieber wrote:
> On Fri, 31 Jan 2014 22:18:34 -0700, Scott W Dunning
> declaimed the following:
>
>> Any chance you guys
On Fri, 31 Jan 2014 22:18:34 -0700, Scott W Dunning wrote:
> Any chance you guys could help with another question I have? Below is a
> code to a different problem. The only thing I don’t understand is why
> when calculating the 'discounted price’ you have to subtract 1? Thanks
> again guys!
pr
On Fri, 31 Jan 2014 18:14:31 -0700, Scott W Dunning wrote:
> little different from a few things you guys had mentioned. For one, I
> got the correct time by calculating the number of time run and
> converting that into seconds then back out to hr:mn:sc. I didn’t
> calculate from midnight.
> SEC
On 1 February 2014 14:17, David wrote:
>
> Scott's message quoted above did not reach me, only Chris's quote of
> it, so I say: Scott once you begin a discussion on a mailing list like
> this one, please make sure that every reply you make goes to
> "python-list@python.org" and not to the individu
Any chance you guys could help with another question I have? Below is a code
to a different problem. The only thing I don’t understand is why when
calculating the 'discounted price’ you have to subtract 1? Thanks again guys!
price_per_book = 24.95
discount = .40
quantity = 60
discounted_pri
Ok cool, thanks Denis!
On Jan 31, 2014, at 8:02 PM, Denis McMahon wrote:
> On Thu, 30 Jan 2014 21:12:19 -0800, scottwd80 wrote:
>
>> Here is the question that was asked and below that I'll paste the code I
>> have so far.
>
> The following is a reasonably but not highly obfuscated short solut
Thanks Chris!
So, this is what I came up with. It works, which is good but it’s a little
different from a few things you guys had mentioned. For one, I got the correct
time by calculating the number of time run and converting that into seconds
then back out to hr:mn:sc. I didn’t calculate
If you’re interested in what the problem is here it is…
Suppose the cover price of a book is $24.95, but bookstores get a 40% discount.
Shipping costs $3 for the first copy and 75 cents for each additional copy.
What is the total wholesale cost for 60 copies?
On Jan 31, 2014, at 10:18 PM, Sc
Also, any help on how to get the hours and seconds into double digits that
would be cool too. 00:00:00
On Jan 31, 2014, at 1:30 AM, Chris Angelico wrote:
> On Fri, Jan 31, 2014 at 7:17 PM, Gregory Ewing
> wrote:
>> sjud9227 wrote:
>>>
>>> Doesn't
>>> assigning seconds/(60*60) mean that calcu
Also, can any of you reccommend sites that may have little “projects” that I
could work on to help me learn python better?
On Jan 31, 2014, at 1:30 AM, Chris Angelico wrote:
> On Fri, Jan 31, 2014 at 7:17 PM, Gregory Ewing
> wrote:
>> sjud9227 wrote:
>>>
>>> Doesn't
>>> assigning seconds/(
You guys are awesome! I think I was over complicating things for one. Plus I
was looking at some code I wrote for another problem that asked to put in the
number of seconds to calculate the problem and I didn’t need some of the things
I added to this problem. Anyways, you guys have given me a
So, this is what I came up with. It works, which is good but it’s a little
different from a few things you guys had mentioned. For one, I got the correct
time by calculating the number of time run and converting that into seconds
then back out to hr:mn:sc. I didn’t calculate from midnight. T
On 1 February 2014 12:34, Chris Angelico wrote:
> On Sat, Feb 1, 2014 at 12:14 PM, Scott W Dunning wrote:
>
>> Also, I think I found out through a little trial and error that I had two
>> different hours, mins, and sec so I had to use one uppercase and one lower
>> case. Is that frowned upon?
On Thu, 30 Jan 2014 21:12:19 -0800, scottwd80 wrote:
> Here is the question that was asked and below that I'll paste the code I
> have so far.
The following is a reasonably but not highly obfuscated short solution to
the problem set in python 2.7. With a bit of luck, after each lesson of
your c
On Sat, Feb 1, 2014 at 12:14 PM, Scott W Dunning wrote:
> Thanks Chris!
>
> Also, before I forget what is the difference between / and //? I remember
> something about floor division?
In Python 2, the / operator by default is "floor division". 5 divided
by 2 is 2. When you divide two integers,
On Sat, Feb 1, 2014 at 11:42 AM, Scott W Dunning wrote:
> Also, any help on how to get the hours and seconds into double digits that
> would be cool too. 00:00:00
Once you can divide the number of seconds into hours, minutes, and
seconds, you can format them like this:
time = "%02d:%02d:%02d"
On 2014-01-31, scottw...@gmail.com wrote:
> Here is the question that was asked and below that I'll paste
> the code I have so far.
>
> **If I leave my house at 6:52 am and run 1 mile at an easy pace
> (8:15 per mile), then 3 miles at tempo (7:12 per mile) and 1
> mile at easy pace again, what tim
Chris Angelico wrote:
OP is using 2.7.6, so short of a __future__ directive, that won't
actually give 6 seconds in hours
Oops, yes, you're right! (I always use future division
these days, so I tend to forget about that.)
and // is unnecessary.
It's still a good habit to get into, though, si
On Fri, Jan 31, 2014 at 7:17 PM, Gregory Ewing
wrote:
> sjud9227 wrote:
>>
>> Doesn't
>> assigning seconds/(60*60) mean that calculating 6*hours will give me 6
>> hours
>> in seconds?
>
> No, it's giving you 6 seconds in hours. (That should
> give you a clue as to what you should have done
> inste
sjud9227 wrote:
Doesn't
assigning seconds/(60*60) mean that calculating 6*hours will give me 6 hours
in seconds?
No, it's giving you 6 seconds in hours. (That should
give you a clue as to what you should have done
instead. :-)
Also, I don't know what you were trying to do with
these two statem
On Thursday, January 30, 2014 11:38:05 PM UTC-7, Chris Angelico wrote:
> On Fri, Jan 31, 2014 at 5:24 PM, sjud9227 wrote:
>
> > Thank you so much Chris. However, i'm still a little confused. Doesn't
> > assigning seconds/(60*60) mean that calculating 6*hours will give me 6
> > hours in second
On Fri, Jan 31, 2014 at 5:24 PM, sjud9227 wrote:
> Thank you so much Chris. However, i'm still a little confused. Doesn't
> assigning seconds/(60*60) mean that calculating 6*hours will give me 6 hours
> in seconds? Also, why calculate how many seconds from midnight? wouldn't it
> just be fr
On Thursday, January 30, 2014 10:30:11 PM UTC-7, Chris Angelico wrote:
> On Fri, Jan 31, 2014 at 4:12 PM, wrote:
>
> > **If I leave my house at 6:52 am and run 1 mile at an easy pace (8:15 per
> > mile), then 3 miles at tempo (7:12 per mile) and 1 mile at easy pace again,
> > what time do I ge
On Fri, Jan 31, 2014 at 4:12 PM, wrote:
> **If I leave my house at 6:52 am and run 1 mile at an easy pace (8:15 per
> mile), then 3 miles at tempo (7:12 per mile) and 1 mile at easy pace again,
> what time do I get home for breakfast?**
>
>
>
> seconds = 1
> hours = seconds / (60*60)
Here is the question that was asked and below that I'll paste the code I have
so far. Any pointers would be great. Please keep in mind this is only my
second week with python (or any programming for that matter) so I have no idea
what I'm doing. How would you code this? Anyways, any help is
69 matches
Mail list logo