15,181 Topics
| |
Hi there. I am trying write a module that can be executed at the command line and for some reason it's not working. Does anyone know why? [CODE]import sys def fibonacci(N): a,b =0,1 while b < N: a,b = b, a+b print b N=sys.argv[1][/CODE] Does it matter that I'm running … | |
Dear All I am working with a tab-delimeted files - first two columns are pairs of identifiers and third column is floating point number (0-1) denoting interaction strength between colmn1 and 2. sample file is also attached. eg- column1 column2 column3 john steve 0.67588 john matt 1.00 red blue 0.90 … | |
could anyone help me regarding calling different python scripts from within a main script.How can this be acheived? Thanks in advance | |
for: [CODE]import random keys='abcdefghijklmnopqrstuvwxyz ' random.choice(keys)[/CODE] How would I count how many times it takes random.choices(keys) to generate "m"? | |
Here's a weird one: I have a Tkinter.Text widget that I import data from with inputText.get(1.0,END) However, later in the program I have the text in an array, but the array has values like: 'u\x00s\x00e\x00r\x00' Is there a way to decode this weird string to a normal string? I think … | |
I have this code: def rollBox(length, numDivisions, count): Angle = 90/numDivisions if count == 0: return elif numDivisions == 0: rollBox(length, numDivisions, count - 1) else: square(length) turtle.right(Angle) rollBox(length, numDivisions - 1, count) Is there any way to still decrease the 'numDivisions' parameter to zero while still keeping its original … | |
could anyone please help me regarding how to add a newline character to the log file created using logging module. All the output is dumped onto a single line, which makes it unreadable. I s there any way to make the log file legible? | |
Hi all. I'm writing a simple GUI to display some text and update the text as I receive data from a multicast address. What I have is a Frame, and then a wxScrolledWindow that is using the Frame as its parent window. The scrolled window contains a vertical box sizer … | |
I'd like to implement a functionality in an app of mine, but I don't know how to go about it. What I want is this: I have a model class that uses imagekit to save its images, and I'd like to have the users being able to update the images … | |
Hi all, I want to know the last event in log ; in other words , when I use this code below : [code] telephone.incoming_call() # waits for an incoming call telephone.call_state(handle_call) [/code] it calls the handle_call function when there is (Answering - Missed - Dialing - Ringing) events , … | |
I am new to python n developing scripts as a part of my project.I need help regarding HOW THE OUTPUT OF THE SCRIPT CAN BE REDIRECTED TO A TEXT FILE(FOR MAINTAINING ERROR LOG), WHILE ALSO PRINTING IT ON CONSOLE?? Thanks for all the help in advance and I am looking … | |
Hi, I have a UI built in Tkinter. The user can type in some inputs and hit "Run" When the "Run" occurs, a program executes that could take 30 seconds or more! The problem is that this blocks the graphics updating. At the beginning, I set a Label to "Running … | |
[CODE]import math import random choices=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,\ 37, 38, 39, 40, 41, 42, 43, 44, 45, … | |
helo! can anyone help me in automatically saving files with fixed filename in python? the OUTPUT would be like this: FILE- A01.txt FILE- A02.txt FILE- B01.txt File- B02.txt i was hoping that i could save a file automatically after making some changes in the older version. Thank you, Gene | |
I need to write a mortgage calculator program that will find the amount of a monthly mortgage payment for a loan. [CODE] # Get information from user print 'CALCULATOR FOR MORTGAGE LOANS' loan_str = raw_input ("Amount of loan:") loan = eval(loan_str) years_str = raw_input("Number of years:") years = eval(years_str) rate_str … | |
Program 1 [CODE]import math class Vectory2(object): def __init__(self, x = 0.0, y = 0.0): self.x = x self.y = y def __str__(self): return "(%s, %s)" % (self.x, self.y) @classmethod def from_points(cls, P1, P2): return cls( P2[0] - P1[0], P2[1] - P1[1] ) def get_magnitude(self): return math.sqrt(self.x**2 + self.y**2) def normalize(self): … | |
Hi, I am coding a program to make a rolling box function using turtle graphics. The box is supposed to appear to be rolling across a floor to the right like this: [url]http://img194.imageshack.us/img194/2944/rollingbox.png[/url] There are supposed to be three function parameters: length for the length of a side, numDivisions for … | |
This might be dumb... but I'm having problems raising e to a negative number and I can't figure out what is going on. [CODE]>>> math.exp(((-23*(23-1))/730)) 0.36787944117144233 >>> math.exp(-506/730) 0.36787944117144233 >>> math.exp(-.69) 0.5015760690660556 >>> math.exp(-(506/730)) 1.0[/CODE] For some reason I keep getting different answers when they should all be the same... … | |
[CODE]import math class Vector2(object): def __init__(self, x = 0.0, y = 0.0): self.x = x self.y = y def __str__(self): return "(%s, %s)" % (self.x, self.y) @classmethod def from_points(P1, P2): return Vector2(P2[0] - P1[0], P2[1] - P1[1]) def get_magnitude(self): return math.sqrt(self.x**2 + self.y**2) def normalize(self): magnitude = self.get_magnitude() self.x /= … | |
I wrote this program for a class, the only problem is that it returns the anwser for assessmentValue twice. I can't figure out what to do to fix it...please help!! [code=php] def main(): #Get the actual value for the property. actualValue = input ("Enter the actual value of the property:$") … | |
Hello. I was wondering if there was a way to use python to convert a video to flash and add controls online. Like youtube, a user uploads a video and it gets converted and controls get added. I have looked online and everyone says "Use this extension blah blah blah" … | |
Hi every one I am facing a problem in deleting items from a list <<< Could any help me !!! [CODE]b=['a', 'b', 'r', 'g'] for c in b: b.remove(c) [/CODE] but when I check b the result is ['b', 'g'] how can I delet all items using for loop thanks | |
Hi, I want to convert a string to numbers ... i tried a lot of codes.. iam a beginner... Kindly help... Ex: a=1 b=2 c=3 d=4 e=5 f=6 g=7 h=8 i=9 j=10 input value -->abc output value --> 123 input value -->abcj output value -->12310 I mean i want to … | |
Ahoy Sailors! So I'm making a Python built application with the Twisted engine, Where size is a slight issue, Currently compiled under Python26 using Py2Exe, The file stands at 1.8MB (With trimmings), Now my script should work using Python 2.4 which also should decrease the file size considerably, However the … | |
I'm attempting to write a game server and I need it to continue on with the code while listening for a connection. I know this is done with the threading module but I don't know how exactly to do this. Python documentation didn't work for me. [CODE] #[LISTENER] print "Initializing … | |
hi there! i'm have a biiig trouble. I've make a simple chatbot, as can learning. The problem is, that I can't insert data into the dictionary without a error. here is the code: [CODE] codes = {} def arraycompare(array1, array2): l = 0 for i in array1: for j in … | |
So I'm writing a bit of code for use in an IRC bot. I tried to use scheduler to get around the barbaric-ness of calling time.sleep() every time I want the bot to delay for a few seconds. In scheduler you can choose the delay function "for example time.sleep()"-- but … | |
I really must have a general misunderstanding of import and global. I'm trying to call a function in an imported file and reference a variable. file1.py [code] from file2 import * x = 6 file2Funct() [/code] file2.py [code] def file2Function(): print x [/code] executing file1 give the following error at … | |
I'm trying to make program using Google 5gram data to compare with one of English exam called TOEIC. There are 118 files for 4grams and each size of 4grams are approximately 300MB and each files has 10,000,000 lines. So, here is the point. It requires about 4 or 5 seconds … | |
I am using python code to transmit data collected (Wii Nunchuck) via I2C wirelessly to another wireless node and then display the information about button press and also roll, yaw and pitch (X,Y,Z) data. The code uses Wx python for frame/window display. Part of the code was copied from the … |
The End.