On Thursday, July 3, 2014 9:11:49 AM UTC-4, MRAB wrote:
> On 2014-07-03 13:51, kjaku...@gmail.com wrote:
>
> > On Wednesday, July 2, 2014 4:02:00 PM UTC-4, MRAB wrote:
>
> >> >
>
> >>
>
> >> If you want 'between' to be an instance method of the MyTime class, it
>
> >>
>
> >> needs 'self' as w
On Thursday, July 3, 2014 9:01:09 AM UTC-4, Chris Angelico wrote:
>
>
>
> And what happens when you run this code? A NameError, I would expect.
>
> Do you understand how to define and call methods?
>
>
>
> ChrisA
Altered the code. But yes a nameerror came up
class MyTime:
def __init__
On Wednesday, July 2, 2014 4:02:00 PM UTC-4, MRAB wrote:
> >
>
> If you want 'between' to be an instance method of the MyTime class, it
>
> needs 'self' as well as the 2 arguments 't1' and 't2'.
>
>
>
> You can then compare the hours, minutes and seconds of self against
>
> those of t1 and t2
I'm trying to write a boolean function that takes two Mytime objects, t1 and t2
as arguments, and returns True if the object falls inbetween the two times.
This is a question from the How to Think Like a Computer Scientist book, and I
need help.
What I've gotten so far:
class MyTime:
def _
I'm trying to create a program that will prompt the user for a list of text
files to read from, then read those text files and build a dictionary of all
the unique words found. Then finally put those unique words into another file
and make it alphabetical order.
What I've got:
import string
s
scores = stu_scores()
for line in scores:
fields = line.split()
name = fields[0]
print (fields)
Error comes up saying "IndexError: list index out of range."
--
https://mail.python.org/mailman/listinfo/python-list
What I've got is
def stu_scores():
lines = []
with open("file.txt") as f:
lines.extend(f.readlines())
return ("".join(lines[11:]))
scores = stu_scores()
for line in scores:
fields = line.split()
name = fields[0]
sum1 = int(fields[4]) + int(fields[5]) + int(fields[6
So let's say I have a file and it looks like this:
Title 1: item
Title 2: item
etc
Is it possible to use a dictionary for something like the input above? Because
I want to be able to use the input above to delete the "Title 1" and "Title 2"
but still show the items (on separate lines).
Basical
Just need a bit of help understanding this so I can actually start it.
The input to a program will come from a file called "asdf.in". This file will
have all the info needed for the course. The formatting of the input file is
described as follows, with denoting # of white spaces and denoting
def choices(n, k):
if k == 1:
return n
if n == k:
return 1
if k == 0:
return 1
return choices(n - 1, k) + choices(n - 1, k - 1)
comb = choices(n, k)
print comb
print ("Total number of ways of choosing %d out of %d courses: " % (n, k))
n = int(input("Number
def choices(n, k):
if k == 1:
return n
if n == k:
return 1
if k == 0:
return 1
return choices(n - 1, k) + choices(n - 1, k - 1)
print ("Total number of ways of choosing %d out of %d courses: " % (n, k))
n = int(input("Number of courses you like: "))
k =
So I need to write a function based off of nCr, which I have here:
def choices(n, k):
if n == k:
return 1
if k == 1:
return n
if k == 0:
return 1
return choices(n - 1, k) + choices(n - 1, k - 1)
It works fine, but then I need to add in so that the user can
On Tuesday, October 8, 2013 11:36:51 AM UTC-4, rand...@fastmail.us wrote:
>
>
>
> Your description says capital letters, but 'a' is a lowercase letter.
>
>
>
> Does "mod 26" means A is 1, or is it 0? i.e., is A+A = B or is it A?
>
>
>
> What should your function do if the letter isn't a ca
On Tuesday, October 8, 2013 10:47:39 AM UTC-4, Robert Day wrote:
> On 08/10/13 15:28, kjaku...@gmail.com wrote:
>
> Can you give some expected outputs? For example, add('A', 'B') should
>
> presumably return 'C', and add('M', 'B') should presumably return 'O',
>
> but what about add('A', 'A')
I have to define a function add(c1, c2), where c1 and c2 are capital letters;
the return value should be the sum (obtained by converting the letters to
numbers, adding mod 26, then converting back to a capital letter).
All I have so far is:
def add(c1, c2):
ord(c1) - ord('a') + 1
ord(c
I ended up with these. I know they're only like half right...
I was wondering if any of you had to do this, what would you end up with?
# Question 1.a
def temp(T, from_unit, to_unit):
if from_unit == 'C' or from_unit == 'c':
return 32 + (9/5)*T
elif from_unit == 'K' or from_unit ==
On Monday, September 23, 2013 10:12:05 PM UTC-4, Denis McMahon wrote:
>
>
> If the first function you wrote allows you to convert temps in different
>
> scales to a common scale, then in the second function, you can call the
>
> first function to convert both temps to a common scale, and comp
On Monday, September 23, 2013 8:07:44 PM UTC-4, Dave Angel wrote:
>
> I didn't see any spec that said Python 3.x. in version 2.x, this would
>
> be incorrect.
>
>
>
> --
>
> DaveA
It's for Python 3.2
--
https://mail.python.org/mailman/listinfo/python-list
On Monday, September 23, 2013 9:56:45 AM UTC-4, Steven D'Aprano wrote:
> On Mon, 23 Sep 2013 05:57:34 -0700, kjakupak wrote:
>
> Now you're done! On to the next function...
>
>
>
> --
>
> Steven
def temp(T, from_unit, to_unit):
conversion_tab
On Monday, September 23, 2013 9:56:45 AM UTC-4, Steven D'Aprano wrote:
> On Mon, 23 Sep 2013 05:57:34 -0700, kjakupak wrote:
>
> Now you're done! On to the next function...
>
>
>
> --
>
> Steven
def temp(T, from_unit, to_unit):
conversion_tab
1.a. Write a function temp(T, from_unit, to_unit) where from_unit and to_unit
are temperature units, either 'F' (or 'f') for fahrenheit, or 'C' (or 'c') for
celsius, or 'K' (or 'k') for kelvin; and T is a temperature number for the unit
from_unit. The function should return the temperature numbe
21 matches
Mail list logo