Re: [Tutor] What is wrong with my Python program that causes it to run but not give results?

2016-10-25 Thread Alan Gauld via Tutor
On 25/10/16 20:24, Ed Troy wrote: > my Ubuntu machine. I created the diode IV curve data as per the article, > but I can't seem to get it to run. > edward@ubuntu:~$ python LED_model_utf8.py LED_IV.txt > Traceback (most recent call last): >File "LED_model_utf8.py", line 4, in > import m

[Tutor] regarding checksum

2016-10-25 Thread Clayton Kirkwood
Small problem: Import zlib For file in files: checksum = zlib.adler32(file) traceback checksum = zlib.adler32(file) TypeError: a bytes-like object is required, not 'str' Obvious question, how do I make a bytes-like object. I've read through the documentation and didn't find a way to do th

Re: [Tutor] What is wrong with my Python program that causes it to run but not give results?

2016-10-25 Thread Marc Tompkins
On Oct 25, 2016 3:07 PM, "Ed Troy" wrote: >I get an error message: > edward@ubuntu:~$ python LED_model_utf8.py LED_IV.txt > Traceback (most recent call last): > File "LED_model_utf8.py", line 4, in > import matplotlib.pyplot as plt > ImportError: No module named matplotlib.pyplot > That la

Re: [Tutor] What is wrong with my Python program that causes it to run but not give results?

2016-10-25 Thread Ben Finney
Ed Troy writes: > I found a very useful Python program for calculating the Spice > parameters for a LED. I have Python3 and the various modules loaded > onto my Ubuntu machine. Which libraries, specifically, have you installed? > When I type python LED_model_utf8.py LED_IV.txt, I get an error m

Re: [Tutor] Alternative to for/while loop

2016-10-25 Thread Bryon Adams
On 10/25/2016 4:31 AM, Wolfgang Maier wrote: On 25.10.2016 10:10, Ben Finney wrote: Bryon Adams writes: I'm very new to python so please forgive what may be a beginner question. Welcome! You are in the right place for asking beginner Python questions :-) I'm thinking there should be a

[Tutor] What is wrong with my Python program that causes it to run but not give results?

2016-10-25 Thread Ed Troy
I found a very useful Python program for calculating the Spice parameters for a LED. I have Python3 and the various modules loaded onto my Ubuntu machine. I created the diode IV curve data as per the article, but I can't seem to get it to run. My python filename is LED_model_utf8.py The text f

Re: [Tutor] Alternative to for/while loop

2016-10-25 Thread Bryon Adams
On 10/25/2016 4:19 AM, Alan Gauld via Tutor wrote: On 25/10/16 02:38, Bryon Adams wrote: question. The book I'm working through hasn't covered using flow control yet so I'm thinking there should be a way to do this without the for loop I used, but I'm at a loss here. Thee are ways to do it wi

Re: [Tutor] Alternative to for/while loop

2016-10-25 Thread Alan Gauld via Tutor
On 25/10/16 09:31, Wolfgang Maier wrote: > A possible explanation is that, as you are saying, the book uses > python2. In python2, input does not return a string, but evaluates the > input from the user to produce different types of objects. So in Python2: Good catch Wolfgang, that's probably w

Re: [Tutor] Alternative to for/while loop

2016-10-25 Thread Alan Gauld via Tutor
On 25/10/16 09:09, niraj pandey wrote: > Try this. > > my_string = '0,1,2,3' > my_lst=my_string.split(",") > leng = len(my_lst) > b=sum(my_lst) > avg=float(b/leng) > print avg It doesn't work because my_list is a list of strings and you can't sum() strings. The loop is needed to convert the strin

Re: [Tutor] Alternative to for/while loop

2016-10-25 Thread Wolfgang Maier
On 25.10.2016 10:09, niraj pandey wrote: Try this. my_string = '0,1,2,3' my_lst=my_string.split(",") leng = len(my_lst) b=sum(my_lst) avg=float(b/leng) print avg better try things yourself before suggesting them to others: >>> my_string = '0,1,2,3' >>> my_lst=my_string.split(",") >>> leng =

Re: [Tutor] Alternative to for/while loop

2016-10-25 Thread niraj pandey
Try this. my_string = '0,1,2,3' my_lst=my_string.split(",") leng = len(my_lst) b=sum(my_lst) avg=float(b/leng) print avg On Tue, Oct 25, 2016 at 7:08 AM, Bryon Adams wrote: > Hello, > I'm very new to python so please forgive what may be a beginner > question. The book I'm working through

Re: [Tutor] Alternative to for/while loop

2016-10-25 Thread Wolfgang Maier
On 25.10.2016 10:10, Ben Finney wrote: Bryon Adams writes: I'm very new to python so please forgive what may be a beginner question. Welcome! You are in the right place for asking beginner Python questions :-) I'm thinking there should be a way to do this without the for loop I used, b

Re: [Tutor] Alternative to for/while loop

2016-10-25 Thread Alan Gauld via Tutor
On 25/10/16 02:38, Bryon Adams wrote: > question. The book I'm working through hasn't covered using flow control > yet so I'm thinking there should be a way to do this without the for > loop I used, but I'm at a loss here. Thee are ways to do it without using a for loop but they are all more a

Re: [Tutor] Alternative to for/while loop

2016-10-25 Thread Ben Finney
Bryon Adams writes: > I'm very new to python so please forgive what may be a beginner > question. Welcome! You are in the right place for asking beginner Python questions :-) > I'm thinking there should be a way to do this without the for loop I > used, but I'm at a loss here. Thank you fo

[Tutor] Alternative to for/while loop

2016-10-25 Thread Bryon Adams
Hello, I'm very new to python so please forgive what may be a beginner question. The book I'm working through hasn't covered using flow control yet so I'm thinking there should be a way to do this without the for loop I used, but I'm at a loss here. So far the book has covered: lists, stri