I am getting some very strange behaviour from the Linear Algebra module.
Look at this code:
from LinearAlgebra import *
a=5
print a
And look at the output that I get when I run it:
50.0
0.0
0.25
0.0
0.5
0.0
0.75
0.0
1.0
[[ 2.5000e-01 -2.5000e-01 -4.3750e-01 ...,
3.73459082e+
Hello, I am attempting to make a simple animation of a vibrating string using
Tkinter canvas.
I haven't been able to find much information on how to do it.
I have my data of position x on the string at time t. I can plot it with
Tkinter showing the string for all times at once:
width=1500
height
I am trying to convert something using the old Numeric module to the numpy
module.
This is the code so far::
from __future__ import division
import pygame, time, random, pygame.sndarray
sample_rate = 44100
from numpy import *
def sine_array(hz,peak,n_samples=sample_rate):
length=sample_rate
Hello, I am a python beginner, and I have a question about scalars vs
arrays.
I am making a (very simple) code, and part of it is:
from numarray import *
from math import *
def source(x,y):
f=sin(x)
return f
a=4.
m=10
dx=a/(m+1.)
x=zeros([m,1], Float)
print x[0]
print func(x[0])
When
Hi everyone, I'm a python noob but I have an ambitious (for me) goal: I
want to make a simple program that allows you to hear combinations of
notes according to a vector of frequencies.
Does anybody know any module that allows you to input a frequency in Hz
and returns a sound with that frequency
This is extremely weird, I think.
Here is a tiny program:
from math import *
from Numeric import *
x=[0]*10
for counter in rangelen((x)):
x[counter]=counter*0.1
print x
Here is what I get:
[0.0, 0.10001, 0.20001, 0.30004,
0.40002, 0.5, 0
How can you make a function accept a variable number of inputs without
any particular limit?
Like when you define a function you usually go:
def func(a,b,c,d,e)
and if you want to give a default value for e you can use e=0 for example.
But what if you want to be able to call the function and pu
I want to thank Emmanuel from the tutor mailing list for showing me a
piece of code that let me do exactly what I wanted - making Python play
a chord from a input of frequencies. I only needed to make a few
adjustments.
The code (below) uses Numeric. Emmanuel said that Numeric is out of date
and s
Actually, I think I can minimize the clipping sound by setting the
sample_rate to be one hundred times the value of the highest frequency
in the chord. But it's still there for the notes underneath. Oh well,
better than nothing!
- Original Message -
From: Mr Gerard Kelly
Date: Thu
I have a problem with understanding how lists, strings, tuples, number
types and input arguments all interact with each other.
I have this program, in which I can use the *a structure to input
unlimited arguments.
As an example, if I use three arguments, it looks like this:
def main():
#Play a
s a way to do this it would be great!
- Original Message -
From: Alan Gauld
Date: Tuesday, January 13, 2009 7:16 pm
Subject: Re: [Tutor] A list of input arguments
> "Mr Gerard Kelly" wrote
>
> >I have a problem with understanding how lists, strings, tuples,
> &g
There is a little Tkinter program. It lets you type something in a box,
and will display it at the command line.
from Tkinter import *
master = Tk()
e = Entry(master)
e.pack()
e.focus_set()
def callback():
s=e.get()
print s
b = Button(master, text="get", width=10, command=callback)
b.pac
If you have a string "6", and you do int("6"), you get the number 6.
But if you have a string "2*3" and you do int("2*3") you get a name error.
How do you take an expression in a string, and evaluate the expression
to get a number?
I want to be able to turn the string "2*3" into the number 6.
t
Thanks very much
I've noticed that the eval() function gives an integer, so eval("3/2")
gives back 1. float(eval("3/2")) doesn't seem to work, any way to get a
floating point number back with eval()?
I know you can just do ("3./2."), but is there any way to do it with
just ("3/2")?
__
I am trying to make a simple Tkinter program using the canvas widget.
All it does take a number (6 in this case) and draw that number of blue
boxes on a canvas.
from Tkinter import *
master = Tk()
numboxes=6
width=40*(numboxes+2)
height=200
w = Canvas(master, width=width, height=height)
w.pack(
gt; On Thu, Jan 15, 2009 at 12:41 AM, Mr Gerard Kelly
> wrote:
>
> > I want to be able to bind these boxes to an event - so that I can
> either> click on them, or hold the mouse cursor over them, and have
> them change
> > color.
>
> Here is a version of your prog
Is there a way to make separate VPython and Tkinter windows run
simultaneously from the one program? Or to have the VPython window run
inside a Tkinter toplevel?
If I have a program that uses both, it seems that one window has to
close before the other will start running.
_
I'm trying to make this very simple program, where the idea is that you
click a tkinter button named "Ball" and then a ball will appear in the
visual window.
Problem is that the window itself doesn't pop up until the button is
pressed and the ball is created. I would like it to start out blank, an
I am trying to get around the problem of sphere object being unindexable.
I need to make spheres appear, positioned according to some list, for
example:
for i in [0,1]:
sphere(pos=(0,i,0), radius=0.1)
Is there any way of making these different spheres behave differently
without using indexi
Sorry, I do see that I wrote that question in a confusing way, but I've
worked out where I was going wrong now. Thanks for taking a look.
- Original Message -
From: Alan Gauld
Date: Friday, February 6, 2009 7:22 pm
Subject: Re: [Tutor] 'sphere' object is unindexable
>
20 matches
Mail list logo