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
==
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 th
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 np.ara
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 asks user for number of
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.
___
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
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.
O
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 whic
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 %
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
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 open(file_path) as a:
> > b
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
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
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)
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 += int(item)
> p
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 wrote:
>You can write y
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?
>
> #Question 10
>
> def reverse(mys
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 - Tutor@pyth
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, A
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':
return
-- 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 bit (AMD64)] on win32
Type "copyright", "cr
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
wrote:
> On 27/08/14 14:40, Jake wrote:
>
>> To whom it may concern,
>> My name is Jake and I have recently sta
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" wrote:
> >
> > Hi,
> >
> > I have string like
> > stmt = 'Patient name: Upadhyay Shyam style="font-family: times new roman
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]), mer
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
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_men
winsound.Beep() takes only integral values for frequency.
Therefore you cannot use it if you want either just intonation or
equal temperment scales exactly.
--
regards,
Sarma.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription
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 wrote:
>
> I've modified my previous script to add simple polyphonic sound. I
> included a basic square wave and a sawtooth wave, plus a random
>
Error: "name data undefined"
On Fri, Sep 14, 2012 at 12:33 AM, eryksun wrote:
> On Thu, Sep 13, 2012 at 11:48 AM, D.V.N.Sarma డి.వి.ఎన్.శర్మ
> wrote:
> >
> > As far as programming volume is concerned winsound.Beep has only
> frequency
> > and duration. pyaudio module appears to have provision
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 wrote:
> On 13/09/2012 13:29, 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.
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 wrote:
> On 13/09/2012 00:57, D.V.N.Sarma డి.వి.ఎన్.శర్మ wrote:
>
>> The Beep attribute of winsound module is useful. But the volume is f
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:
>
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 wrote:
> On 12/09/12 14:53, D.V.N.Sarma డి.వి.ఎన్.శర్మ wrote:
>
>> My OS is Windows XP. I have Python 2.7.3(32 bit).
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.
--
regar
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
36 matches
Mail list logo