Re: [Tutor] Is there a better way to write my code?

2018-08-14 Thread Neil Cerutti
p, or when you can take advantage of set operations, like union or symmetric difference. If your list of chickens is unordered and has no duplicates, using a set instead is often a good refinement. -- Neil Cerutti ___ Tutor maillist - Tutor@python.

Re: [Tutor] Is there a better way to write my code?

2018-08-13 Thread Neil Cerutti
uot;SuperLion", "Cow", "Panda"] You can perform the whole operation with a single list comprehension. animals_lol = [[a, len(a)] for a in animals] Which is shorthand for the following loop: animals_lol = [] for a in animals: animals_lol.append([a, len(a)]) -- Ne

Re: [Tutor] tab separated file handling

2018-06-13 Thread Neil Cerutti
On 2018-06-13, Niharika Jakhar wrote: > hi everyone! > I am working with a tsv file which has NA and empty values. > I have used csv package to make a list of list of the data. > I want to remove NA and empty values. Should the the data 40 50 NA 12 mean the same thing as 40 50 1

Re: [Tutor] Iteration issues

2018-05-11 Thread Neil Cerutti
l the apostrophes and dashes, both of which could be considered parts of words. -- Neil Cerutti ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Dict of Dict with lists

2018-04-26 Thread Neil Cerutti
re might in fact be > some behaviour that these login records might acquire within > the system. For example formatted printing, comparisons between > records etc etc. Excellent point! At the very least, such classes usually gain the ability to build themselves with an __init__ method, wh

Re: [Tutor] Help!

2018-04-19 Thread Neil Cerutti
ir atomic weights, and the total > molecular weight. > > Convert between temperature scales (degrees Celsius, Fahrenheit, and > Kelvin). Excellent suggestions. It could also be fun to build a text-based solitaire program of your choice. -- Neil Cerutti ___

Re: [Tutor] PLEASE HELP

2018-04-13 Thread Neil Cerutti
On 2018-04-13, David Rock <da...@graniteweb.com> wrote: > >> On Apr 13, 2018, at 09:24, Neil Cerutti <ne...@norwich.edu> wrote: >> >> On 2018-04-12, Scharrer, Brianna <bschar...@luc.edu> wrote: >>> Applications of basic language syntax >&g

Re: [Tutor] PLEASE HELP

2018-04-13 Thread Neil Cerutti
nteger (as Alan discussed) I recommend using a dictionaries for conversion, rather than if statements, if you're allowed. -- Neil Cerutti ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] XML parsing

2018-03-30 Thread Neil Cerutti
On 2018-03-30, Stefan Behnel <stefan...@behnel.de> wrote: > Neil Cerutti schrieb am 30.03.2018 um 15:50: >> On 2018-03-30, Stefan Behnel wrote: >>> I admit that I'm being a bit strict here, there are certainly >>> cases where parsing the namespace from a tag i

Re: [Tutor] XML parsing

2018-03-30 Thread Neil Cerutti
o that, it's worth reconsidering (or > asking) if you are doing the right thing. Namespaces hurt my head when I try to imagine a use for them. The only one's I've encountered are just applied to an entire document, making parsing more inconvenient but providing no other benefit I can s

Re: [Tutor] Fwd: Need help with reading and cleaning CSV files for a class

2018-01-29 Thread Neil Cerutti
has to be changed into well-formed? That's sounds like a fun and challenging problem. -- Neil Cerutti ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Floating decimal question

2017-12-19 Thread Neil Cerutti
finite representations in decimal notation. For your specific problem, you can use Python's format function, for example: >>> for i in range(1, 11): print('{:.4f}'.format(1 / i)) 1. 0.5000 0. 0.2500 0.2000 0.1667 0.1429 0.1250 0. 0.1000 -- Neil Cerutti __

Re: [Tutor] Aggregation vs Composition

2017-12-11 Thread Neil Cerutti
ects cannot exist independently of their parent. In other words, in the text aggregation is a generlisation of composition. -- Neil Cerutti ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Counting iterations of a function

2017-11-30 Thread Neil Cerutti
liminate the verbatim repetition of code. def get_query(): return input("Please type in your question(press 'Enter' to exit):") In main: query = get_query() while query!='': oracle() count += 1 query = get_query() You can generalize

Re: [Tutor] How to test for the existence of a table in a sqlite3 db?

2017-10-19 Thread Neil Cerutti
On 2017-10-19, Alan Gauld via Tutor <tutor@python.org> wrote: > On 18/10/17 21:09, Albert-Jan Roskam wrote: >> >> On Oct 16, 2017 15:12, Neil Cerutti <ne...@norwich.edu> wrote: > >>> sqlite3 module. In sqlite modifying table definitions is limited >>

Re: [Tutor] How to test for the existence of a table in a sqlite3 db?

2017-10-16 Thread Neil Cerutti
to use. Your main goal, at first, should be to stick with standard SQL as much as you possibly can, to make it easier to switch database engines should you ever wish to do so. -- Neil Cerutti ___ Tutor maillist - Tutor@python.org To unsubscribe or ch

Re: [Tutor] When to use classes

2017-08-22 Thread Neil Cerutti
ious ways of doing things. Sometimes I use classes simply because it provides a convenient way to organize the project's functions. This crops up sometimes when I'm translating some data into another form. Every object translates into itself. -- Neil Cerutti ___

Re: [Tutor] Long post: Request comments on starting code and test code on chess rating project.

2017-08-17 Thread Neil Cerutti
On 2017-08-16, boB Stepp <robertvst...@gmail.com> wrote: > On Tue, Aug 15, 2017 at 12:29 PM, Alan Gauld via Tutor > <tutor@python.org> wrote: >> On 15/08/17 15:09, Neil Cerutti wrote: >>>> There are a variety of reports that I would like to be able >&

Re: [Tutor] Long post: Request comments on starting code and test code on chess rating project.

2017-08-15 Thread Neil Cerutti
area for me, but I see no reason why my > two dictionaries cannot be manipulated to pull the desired > results for each imagined type of report. You really can do it, but to me this requirement argues for going back to a database backend. Why rewrite SQL? -- Neil Cerutti

Re: [Tutor] Fahrenheit to Celsius Conversion another problem and Programming Paradigm

2017-06-15 Thread Neil Cerutti
return "Celsius" > ... return "unknown" > ... >>>> check("c") > 'Celsius' >>>> check("C") > 'Celsius' >>>> check("F") > 'unknown' > > Fine so far. But now: > >>>>

Re: [Tutor] Count for loops

2017-04-05 Thread Neil Cerutti
ngs-in-strings > cases. Composing a FSA (finite state automata) by hand would be an excellent exercise in addition to covering the overlapping cases. Another fun exercise might be to find the bithdays using arithmetic operations instead of string operations. -- Neil Cerutti __

Re: [Tutor] Merge Sort Algorithm

2017-03-30 Thread Neil Cerutti
s with small, easy-to-think-about test cases, and slowly build them up. Do not try to debug by starting with a typical case. -- Neil Cerutti ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] for: how to skip items

2014-02-18 Thread Neil Cerutti
on range objects. x[::10] range(0, 100, 10) So we've got *that* going for us. -- Neil Cerutti ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Beginner - explaining 'Flip a coin' bug

2014-02-13 Thread Neil Cerutti
is a major failure. I'm living in the past, man! -- Neil Cerutti ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Beginner - explaining 'Flip a coin' bug

2014-02-12 Thread Neil Cerutti
are using to read this mailing list, or at least to change your assumption when you see a contentless message from Original poster didn't send email to I can't see the email. This is also a USENET newsgroup, where attachements are not a thing. -- Neil Cerutti

Re: [Tutor] Which computer operating system is best for Python

2014-02-06 Thread Neil Cerutti
on it. If not, it's just inviting needless headaches. -- Neil Cerutti ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] learning recursion

2014-02-06 Thread Neil Cerutti
of your algorithm adjusted accordingly. -- Neil Cerutti ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor