[Tutor] anomaly

2018-04-19 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
I have a situation in which the same code gives an error in idle but works in qtconsole regards, *​in idle* v = np.zeros(len(x)) for i in range(len(x)): if x[i] < 1.0: v[i] = 0 else: v[i] = V print v​ RESTART: C:\Users\SHARMA\Documents\Python Scripts\sqwell.py

Re: [Tutor] coding help with maxwell-boltzmann distribution

2017-10-13 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
Yes we can vectorize. regards, Sarma. On Fri, Oct 13, 2017 at 9:43 PM, Peter Otten <__pete...@web.de> wrote: > D.V.N.Sarma డి.వి.ఎన్.శర్మ wrote: > > f = np.zeros(40) > > v = np.arange(0,4,0.1) > > for i in np.arange(0, 40): > > f[i] = v[i]**2*(np.exp(-v[i]**2)) > > Note that you can write

Re: [Tutor] coding help with maxwell-boltzmann distribution

2017-10-13 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
Except for some constants the essential behaviour of Maxweell-Boltzmann distribution is determined by v**2 * exp(-v**2) The following code will gove you a plot of the shape of the curve. from matplotlib import pyplot as plt import numpy as np f = np.zeros(40) v = np.arange(0,4,0.1) for i in

Re: [Tutor] Require help for a script

2017-09-19 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
First fill the first row and first column of the matrix with seperate loops. Then the rest of the elements of the matrix can be filled with nested loops. regards, Sarma. On Tue, Sep 19, 2017 at 1:18 PM, Clara Chua wrote: > Hi Python tutor, I require help for a script that

[Tutor] Image i/o in python

2017-07-16 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
In python we have a set of imread and imshow in skimage. In matplotlib.image we again have imreadand imshow functions. In scipy.misc we again have another set imread and imshow. Are there anyfunctional differences between these multiple sets to justify their presence? … regards, Sarma.

Re: [Tutor] reg. list update

2017-04-17 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
This is an aliasing problem. Change the code to super = [] sub = [""]*3 other = ["a","b","c","d"] sub[0] = "hi" sub[1] = "hello" for item in other: l = sub[:] l[2] = item super.append(l) for item in super: print item regards, Sarma. On Tue, Apr 18, 2017 at 2:16 AM, Mats Wichmann

Re: [Tutor] sorted function

2017-04-14 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
Change your code to def front_x(words): # +++your code here+++ ls=[] ls1=[] for str in words: if str[0]=='x': ls.append(str) else: ls1.append(str); print ls print ls1 ls = sorted(ls) ls1 = sorted(ls1) ls.extend(ls1) return ls regards, Sarma.

Re: [Tutor] Count for loops

2017-04-12 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
A lot of confusion is caused by the print function converting an integer or float to a string before printing to console. thus both '1234 and '1234' are shown as 1234 on the console. Similarly '15.4' and 15.4 are displayed as 15.4. There is no way to tell which is a string, which is an int and

Re: [Tutor] Count for loops

2017-04-03 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
Small correction. file_path = "C:/Users/Rafael/PythonCode/PiDigits.txt" with open(file_path) as a: b = a.read() get_year = input("What year were you born? ") count = 0 b= '3'+b[2:] n = len(b) for i in range(n-3): if b[i:i+4] == get_year: count += 1 print("Your birth date occurs

Re: [Tutor] Count for loops

2017-04-03 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
I will go for this modification of the original code. file_path = "C:/Users/Rafael/PythonCode/PiDigits.txt" with open(file_path) as a: b = a.read() get_year = input("What year were you born? ") count = 0 b= '3'+b[2:] n = len(b) for i in range(n-4): if b[i:i+4] == get_year: count

Re: [Tutor] Count for loops

2017-04-03 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
Sorry. That was stupid of me. The loop does nothing. regards, Sarma. On Mon, Apr 3, 2017 at 8:44 PM, Alan Gauld via Tutor wrote: > On 03/04/17 16:07, D.V.N.Sarma డి.వి.ఎన్.శర్మ wrote: > > Modifying the code as shown below may work. > > I doubt it. > > > with

Re: [Tutor] Count for loops

2017-04-03 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
Modifying the code as shown below may work. file_path = "C:/Users/Rafael/PythonCode/PiDigits.txt" with open(file_path) as a: b = a.read() get_year = input("What year were you born? ") count = 0 for year in b: if get_year in b: count += 1 print("Your birth date occurs %s times in

Re: [Tutor] Calculate 4**9 without using **, was Re: QUESTION

2017-03-04 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
Much simpler is 4*4*4*4*4*4*4*4*4 regards, Sarma. On Sat, Mar 4, 2017 at 2:20 PM, Peter Otten <__pete...@web.de> wrote: > Tasha Burman wrote: > > > Hello python tutors, > > I am having difficulty with a power function; what is another way I can > do > > 4**9 without using **? Thanks, > > Hello

Re: [Tutor] Adding numbers within a string

2016-10-13 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
Then Isaac's function does that(but you have to leave a space after last number in the string). def foo(x): a, b = 0, "" for i in x: if i != " ": b += i else: print ("this is b", b) a += int(b) print ("this is a",a)

Re: [Tutor] Adding numbers within a string

2016-10-12 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
Sorry, I did not read the conditions that split and for should not be used. regards, Sarma. On Wed, Oct 12, 2016 at 10:20 PM, D.V.N.Sarma డి.వి.ఎన్.శర్మ wrote: > def string_sum(s): > total = 0 > items = s.split(" ") > for item in items: >total

Re: [Tutor] Adding numbers within a string

2016-10-12 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
def string_sum(s): total = 0 items = s.split(" ") for item in items: total += int(item) print(total) You can call the function as string_sum("10 4 5 ") Output will be 19. regards, Sarma. On Wed, Oct 12, 2016 at 3:22 PM, hell gates

Re: [Tutor] Python Code Not Working

2016-10-11 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
An easier solution is simply to type 'print' in place of 'test' in the program. It will work. regards, Sarma. On Mon, Oct 10, 2016 at 2:09 AM, wrote: > Everytime I run this it says test is not defined . I don’t understand. Can > someone please help correct? > >

Re: [Tutor] maximum recursion error

2016-09-16 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
Can somebody tell me why my IDLE hangs when asked setrecursionlimit. >>> x=GetSet(40) >>> x.var 40 >>> x.__dict__ {'var': 40} >>> del x.var >>> x.__dict__ {} >>> import sys >>> sys.setrecursionlimit(7) regards, Sarma. ___ Tutor maillist -

Re: [Tutor] Problem

2016-08-29 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
The following code should do. for a in range(1,10): for b in range(1,5): for c in range(1,5): for mc in range(50, 55): if mc ==(6*a)+(9*b)+(20*c): print "mc= ",mc,"a= ",a,"b= ",b,"c=",c regards, Sarma. On Mon, Aug 29, 2016 at 3:34 PM,

Re: [Tutor] Fw: URGENT: PYTHON QUESTION

2016-03-31 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
This is working fine. What is the problem? def manipulate_data(kind, data): if kind == 'list': return list(data)[::-1] elif kind == 'set': #data=set({"a", "b", "c", "d", "e", "ANDELA", "TIA", "AFRICA"}) return set(data) elif kind == 'dictionary':

[Tutor] Fwd: Citing Python

2016-03-16 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
-- Forwarded message -- From: D.V.N.Sarma డి.వి.ఎన్.శర్మ Date: Wed, Mar 16, 2016 at 3:39 PM Subject: Re: [Tutor] Citing Python To: Steven D'Aprano "Python 2.7.11 |Anaconda 2.5.0 (64-bit)| (default, Jan 29 2016, 14:26:21) [MSC v.1500 64

Re: [Tutor] Python Programming

2014-08-27 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
change the line if answera == [Oslo or oslo]: to if answera == Oslo or answera == oslo: and see if it works. regards, Sarma. On Thu, Aug 28, 2014 at 12:27 AM, Alan Gauld alan.ga...@btinternet.com wrote: On 27/08/14 14:40, Jake wrote: To whom it may concern, My name is Jake and I have

Re: [Tutor] re module

2014-08-14 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
I tested it on IDLE. It works. regards, Sarma. On Thu, Aug 14, 2014 at 7:37 PM, Chris “Kwpolska” Warrick kwpol...@gmail.com wrote: On 14 Aug 2014 15:58 Sunil Tech sunil.tech...@gmail.com wrote: Hi, I have string like stmt = 'pspan style=font-size: 11pt;span style=font-family:

[Tutor] A mergesort

2013-08-31 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
I have been searching for mergesort implimentations in python and came across this. def merge(a, b): if len(a)*len(b) == 0: return a+b v = (a[0] b[0] and a or b).pop(0) return [v] + merge(a, b) def mergesort(lst): if len(lst) 2: return lst m = len(lst)/2 return merge(mergesort(lst[:m]),

Re: [Tutor] python help!

2013-02-09 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
I have altered the program to run on Python 2.7.3 Perhaps it will run on Python 3 with small/or no alterations. def show_menu(): print(===) print(1-binary to denary) print(2-denary to binary) print(3-exit) print(===) while True: show_menu()

Re: [Tutor] python help!

2013-02-09 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
Remove also 'continue' statement under the 'if denary2 not in range(0,256)' clause. On Sun, Feb 10, 2013 at 7:06 AM, D.V.N.Sarma డి.వి.ఎన్.శర్మ dvnsa...@gmail.com wrote: I have altered the program to run on Python 2.7.3 Perhaps it will run on Python 3 with small/or no alterations. def

Re: [Tutor] Musical note on python

2012-09-13 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
I want to thank all of you who have come forward to help me. -- regards, Sarma. On Thu, Sep 13, 2012 at 10:46 AM, D.V.N.Sarma డి.వి.ఎన్.శర్మ dvnsa...@gmail.com wrote: Yes. As far as I can see it does not contain any thing which concerns the volume of sound. -- regards, Sarma. On

Re: [Tutor] Musical note on python

2012-09-13 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
As far as programming volume is concerned winsound.Beep has only frequency and duration. pyaudio module appears to have provision for volume control. Please refer to eryksun's post. -- regards, Sarma. On Thu, Sep 13, 2012 at 8:42 PM, Mark Lawrence breamore...@yahoo.co.ukwrote: On 13/09/2012

Re: [Tutor] Musical note on python

2012-09-13 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
Error: name data undefined On Fri, Sep 14, 2012 at 12:33 AM, eryksun eryk...@gmail.com wrote: On Thu, Sep 13, 2012 at 11:48 AM, D.V.N.Sarma డి.వి.ఎన్.శర్మ dvnsa...@gmail.com wrote: As far as programming volume is concerned winsound.Beep has only frequency and duration. pyaudio module

Re: [Tutor] Musical note on python

2012-09-13 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
This worked on my computor. Thank you. It will take me sometime to digest the program. -- regards, Sarma. On Fri, Sep 14, 2012 at 12:33 AM, eryksun eryk...@gmail.com wrote: I've modified my previous script to add simple polyphonic sound. I included a basic square wave and a sawtooth wave,

Re: [Tutor] Musical note on python

2012-09-12 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
My OS is Windows XP. I have Python 2.7.3(32 bit). My question is are there any commands in Python which directly allow me to produce a pure note of a given frequency, given volume and given duration. Further can we access the different sound channels(sound card) available through Python. --

Re: [Tutor] Musical note on python

2012-09-12 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
The Beep attribute of winsound module is useful. But the volume is feeble. Is there anyway to control the loudness. -- regards, Sarma. On Thu, Sep 13, 2012 at 4:45 AM, Alan Gauld alan.ga...@btinternet.comwrote: On 12/09/12 14:53, D.V.N.Sarma డి.వి.ఎన్.శర్మ wrote: My OS is Windows XP. I have

Re: [Tutor] Musical note on python

2012-09-12 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
One can ofcourse increase the volume by adjusting master volume. But one needs ability to program volume level in order to produce sounds of different volume levels in a piece of music. -- regards, Sarma. On Thu, Sep 13, 2012 at 5:27 AM, D.V.N.Sarma డి.వి.ఎన్.శర్మ dvnsa...@gmail.com wrote:

Re: [Tutor] Musical note on python

2012-09-12 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
Yes. As far as I can see it does not contain any thing which concerns the volume of sound. -- regards, Sarma. On Thu, Sep 13, 2012 at 5:42 AM, Mark Lawrence breamore...@yahoo.co.ukwrote: On 13/09/2012 00:57, D.V.N.Sarma డి.వి.ఎన్.శర్మ wrote: The Beep attribute of winsound module is useful.

[Tutor] Musical note on python

2012-09-11 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
How to produce a musical note of given frequency,volume and duration in Python. -- regards, Sarma. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor