15,190 Topics
![]() | |
Hey guys, this code is supposed to remove all the spaces at the end of each line. However from what I can tell it prints out the exact same file again instead of removing nothing. Have I been using the wrong test files? Or is there something wrong with my … | |
i want to make a program that has a player take on the computer in a game of Rock Paper Scissors. The GUI should have an appropriate lable at the top. it should allow the player to select his or her weapon of choice. program should have a fight button … | |
It's been a while since I bugged you guys. But I need the council of my wise advisers once more. I am trying to write a program that reads a .txt file, breaks each line into words, strips the whitespace and punctuation from the words and returns them in lowercase. … | |
I making a game that would use multiple canvases drawing on one canvas then switching to another... is there any way to get a new canvas and be able to restore the old canvas with the drawings still on it? | |
Hello! Now I have written a function for numbers over 3999: if arabicnumber<=3999: print arabToRom else: parenthesis=0 while (arabicnumber)>3999 arabicnumber/=1000 for i in range (parenthesis... etc and i compare all the numbers that i write in so if i write like 5560 it pirints out ( V ) and the … | |
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] … | |
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 … | |
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 … | |
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 … | |
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! | |
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 … | |
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"] = … | |
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 :) | |
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 … | |
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 … | |
[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']) … | |
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 … | |
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: … | |
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 … | |
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 … | |
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 … | |
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, … | |
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. | |
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 … | |
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 … | |
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 … | |
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 … | |
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. … | |
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, … | |
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 … |
The End.