15,185 Topics

Member Avatar for
Member Avatar for Hawkeye Python

Hi! I'm new at python and I don't get the while statement. I'm trying to make a simple function that returns each term of a geometric progression 'til 'n'. [CODE]def gp(a1,r,n): while not n == 0: n = n - 1 an = a1 * (r ** n) return an[/CODE] …

Member Avatar for Hawkeye Python
0
147
Member Avatar for Binika

I would really need some help :( Write a recursive method, as a parameter to accept the folder name (absolute or relative to the current folder) that prints lists of all the files and all folders in the folder, which is given in parameter, and displays all folders in all …

Member Avatar for TrustyTony
0
214
Member Avatar for evertron

I tried this class a couple of different ways and I had it print just memory location I think one way now I have an error that says: Traceback (most recent call last): File "F:\Python_Stuff\CSC143-901\Lexicon.py", line 83, in <module> source = Lexicon.OpenFile('word') TypeError: unbound method OpenFile() must be called with …

Member Avatar for evertron
0
233
Member Avatar for MaC-CK

Good morning, I'm learning some basic programming and fundamentals and I am having a hard time troubleshooting why a certain part of my code is not working. In my "calcTotal" function, my If, Else statements do not seem to be working. The program runs through, but the output is always …

Member Avatar for MaC-CK
0
133
Member Avatar for tk-421

I need help! The Python program I need to write accepts the price of an item, the amount paid for it, and then calculates the change in the smallest number of bills/coins. I'm so lost! Can anyone help? Thanks!

Member Avatar for TrustyTony
0
13K
Member Avatar for ultimatebuster

I'm curious on how would one accomplish event driven programming from a language like python (or other, but for simplicity sake, python will do.). By that I mean providing a system that allow programmer to hook functions to certain events, and fire those events when triggered. (Basically the APIs behind …

Member Avatar for ultimatebuster
0
153
Member Avatar for Thropian

if been using python's tkinter for awhile to write programs when I caused an issue that I'm not sure what is my code is long even after I gutted it. [CODE]from Tkinter import * import random import operator info_dict = {} info_dict["area"] = 1 info_dict["slime_spot"] = random.randint(1,36) info_dict["slime spotter"] = …

Member Avatar for Thropian
0
110
Member Avatar for ciliath

so i am creating this message field with [CODE]self.text = wx.TextCtrl(panel, pos=(150,22),size=(100,20))[/CODE] and it works, no problem but i'd like that the text gets written from the right and not the left which is a pain... anyone have a slight clue on how to do it ? help appreciated :)

Member Avatar for ciliath
0
221
Member Avatar for ljjfb

Hi all professionals, I uesd subprocess module to spawn a new process and then implement the command. The final result is the output via stdout. Here is the code I wrote: [CODE] import subprocess proc = subprocess.Popen('egrep '^HTTP/' *', shell=True, stdout=subprocess.PIPE,) stdout_value = proc.communicate()[0] print 'results:' print stdout_value [/CODE] And …

Member Avatar for richieking
0
190
Member Avatar for Favolas

Hello. I'm new in Python and I only want to use basic programing skills. I have this example code: [CODE] list_a = [a, ] * 15 list_b = [b,] s = 5 n = 2 [/CODE] and want to obtain this: [CODE] [b,b,a,a,a,a,a,b,b,b,b,a,a,a,a,a,b,b,b,b,a,a,a,a,a,b,b] [/CODE] basically I want to insert list_b …

Member Avatar for woooee
0
110
Member Avatar for sandesh56

[CODE] C={} D={} C['21600']=[{'vid':1,'route':[11,12,13,14,15]},{'vid':2,'route':[21,22,23,24,25]}] C['23500']=[{'vid':3,'route':[31,32,33,34,35]},{'vid':4,'route':[41,42,43,44,45]}] #D['21600']=[{'vid':1,'route':[11,12,13]},{'vid':2,'route':[23,24,25]}] #D['23500']=[{'vid':3,'route':[31,32]},{'vid':4,'route':[45]}] D=C for n in D: for n2 in D[n]: if n2['vid']==1: n2['route'].remove(14) n2['route'].remove(15) elif n2['vid']==2: n2['route'].remove(21) n2['route'].remove(22) elif n2['vid']==3: n2['route'].remove(33) n2['route'].remove(34) n2['route'].remove(35) elif n2['vid']==4: n2['route'].remove(41) n2['route'].remove(42) n2['route'].remove(43) n2['route'].remove(44) print 'Printing D ', D for u in D: for u2 in D[u]: print len(u2['route']) …

Member Avatar for woooee
0
132
Member Avatar for yellowkaiq

So I have the y and e endings down, just need some help with the middle. Basically, I need to double the last letter before adding er if: the last letter is b,d,g,l,m,n,p,r,s or t and the second to last letter is not the same as the last letter. [CODE]def …

Member Avatar for yellowkaiq
0
185
Member Avatar for blacknred

I'm trying to parse xml file and convert all the unix timestamps in it to datetime... [QUOTE]<Sample> <TimeStamp>1291052077</TimeStamp> blah blah blah blah </Sample> <Sample> <TimeStamp>1291052077</TimeStamp> blah blah blah blah </Sample> </Content>[/QUOTE] [CODE]import fileinput file = raw_input("Enter file: ") file = open(file, "wb+") for line in fileinput.FileInput(file,inplace=1): if "TimeStamp" in line: …

Member Avatar for richieking
0
186
Member Avatar for king_koder

The [URL="http://www.python.org/"]official Python website[/URL] is now conducting a poll to find what Python package users want most to get ported to Python 3. Top on the list is django followed by wxPython and numpy. See the full results at- [url]http://www.python.org/3kpoll[/url]. Also, do vote(or nominate) the Python package that you want …

Member Avatar for richieking
1
92
Member Avatar for michaeljfox

So my teacher wants us to design a short program to add 2 polynomials, asking the user for the degree and coefficients, and print out the new coefficients. ie: poly1 deg=2 coeff= 3 4 5 poly2 deg=2 coeff= 2 5 6 output would be: 5 9 11 however, sometimes one …

Member Avatar for TrustyTony
0
2K
Member Avatar for Harris00

Hello I have below code to draw the circle, i want to add vertical line dividing the circle half and horizontal line and cross lines like in attached document. all the lines divide the circle equally with 45 degrees angle. I really appreciate the guidance from turtle import * r=100 …

Member Avatar for richieking
0
1K
Member Avatar for Zealhack

The code below just makes it have one letter/number per line then it forms a new line, but I would like to have the numbers on each line and only form a new line everywhere there is a comma. Is there a way to do this? Thanks! [code] def hyp(aFile, …

Member Avatar for Zealhack
0
179
Member Avatar for bretthay93

write a program code thathas two functions: first() and second(). Function first() should print the string "in function first()" and then call function second()> functions second() should print the string "in function second()". in the global scope, you should call function first.

Member Avatar for WildBamaBoy
0
144
Member Avatar for M3M69

Goodafter noon all, i would like some help on how to modify a python program to do the following: 1. Read both files actors.small.list and actresses.small.list and, using a dictionary, build a database that maps from each actor to a list of his or her films. 2. Two actors are …

Member Avatar for M3M69
0
123
Member Avatar for longlongsilver

i need the code to ask the play for a guess with a call to ask_number() here is my code i have a problem in that it won't run can somebody offer me some help? thanks [CODE]import random secretNum = random.randrange(100)+1 tries = 0 while tries < 5: try: def …

Member Avatar for TrustyTony
0
214
Member Avatar for afireinside

Hello, I have about 500,000+ txt file for about 7+ gigs of data total. I am using python to put them into a sqlite database. I am creating 2 tables, 1. is the pK and the hyperlink to the file. For the other table I am using an entity extractor …

Member Avatar for woooee
0
1K
Member Avatar for danholding

im a newbie to python still so bare with me if i have gone down the wrong route or my explanation is confusing!! any ideas on how i can sort my list by the size of the file at the moment it is getting the size of the file and …

Member Avatar for TrustyTony
0
239
Member Avatar for kshaaban

Hey everyone! I have been working on some c++ code which point tracks a user and extrapolates their co-ordinates within 3D space. i have the co-ordinates in c++ stored as variables and would like to use these variables within the Blender game engine to position an object within the scene. …

Member Avatar for kshaaban
0
207
Member Avatar for kafro

I have a .txt file with some data in it that I would like to transfer into a tuple. I'm able to do that but am having trouble with the format I would like it in. If my .txt file looks something like: North America, 1, 5 South America, 2, …

Member Avatar for group256
0
217
Member Avatar for tachyonshower

hi, i had posted before but decided to just give it a go on my own. now i am sort of in a similar spot with my code. i am modeling an oscillatory system by coupling spring-masses in a lattice formation. i would ideally like to have a second lattice …

Member Avatar for tachyonshower
0
197
Member Avatar for johanngomes

(Python begginner, please be gently) Hi, i'm having some troubles with turning one python project i made into an executable, using py2exe (via GUI2EXE). The program is compilling well, it generates the executable, but when i try to execute it, i get the following error: ImportError: No module named twitter …

0
56
Member Avatar for kshaaban

Hi everyone, i was wondering how it might be possible to send variables from a programme written in c++ to be used in a separate application which is coded in python. I am using opencv to calculate points of interest in c++. I would then like these resulting co ordinates …

Member Avatar for kshaaban
0
306
Member Avatar for jrp370

im trying to create a function that does the same thing as the built in list opperation for index with out using the built in command for it. what i mean is i cant have a list lets say myList=[1,2,3,4,5] i then cant simply go mylist.index(3) any idea on how …

Member Avatar for TrustyTony
0
107
Member Avatar for convoluted

Hey all. Let's say I would like to periodically poll for a change in a variable/device/etc. Obviously I would like to use an infinite loop and when need be, break from the loop to end the polling routine. What I don't what to do is peak my processor usage by …

Member Avatar for convoluted
0
190
Member Avatar for Finki

This are some exercises for my exam. Need some help ASAP. Program for 9 or 10 points would be the best, because I only need that for exam. [B]6 points:[/B] Write a program that reads a file .picasa.ini and copies pictures in new files, whose names are the same as …

Member Avatar for woooee
-2
196

The End.