15,181 Topics

Member Avatar for
Member Avatar for mkbear

Hey so Im a beginner, and I need some help. My professor gave us this code: def average(list): total = 0.0 for number in list: total += number return total / len(list) Then, he asked us to rewrite that program so that it uses a while loop instead. So far …

Member Avatar for inuasha
0
219
Member Avatar for arindam31

Hi Everyone, I am trying to call a function after every T secs . When i use time.wait() , the app hangs, i do not have control over the app. For now , this programs will do the process once , and then after T secs . But i do …

Member Avatar for arindam31
0
281
Member Avatar for Ice_Occultism

I seem to be having a problem importing functions from a file whenever I use the wildcard "*". [code]from text import *[/code] Raises this error: NameError: global name '_Star' is not defined However, if I ask it to import the Function names' manually like so: [code]from text import _Star, _Zero, …

Member Avatar for Ice_Occultism
0
139
Member Avatar for vaucro

Hi everyone i'm very new to python , only have been working with it for about a week, and I have the following question.I'm making a Lingo game in which you guess a needed word, but the first letter is always given when started I have 3 lists in which …

Member Avatar for vaucro
0
693
Member Avatar for Edwards8

I need to insert some rows into Excel. I know it can be done via xlApp.ActiveWorkbook.ActiveSheet.Rows("10:10").Insert() But what I need to know, is if I can use variables in place of the 10's. I need to insert rows at various places throughout an excel document, and input data into those …

Member Avatar for jvangeld
0
259
Member Avatar for tjy92

How would you write this program in Python IDLE? Write a program with a function that accepts a string as an argument and returns (some type of return value) a copy of the string with the first character of each sentence capitalized. For instance, if the argument is "hello. my …

Member Avatar for TrustyTony
0
3K
Member Avatar for spidymac

print "Aloha World" [CODE][/CODE] print "I'm currently living in Hawaii and gaining my AS @ Honolulu Community College" print " Also happily married with four lovely daughters and my boy due in mid-February 2012" print "really enjoy Basketball, and working hands on-with technology" print "work part-time at the Geek Sqaud, …

Member Avatar for Netcode
0
18
Member Avatar for Accendo

I have to create a dictionary using only capital letters and I need to store the bit value too. The capital letters however are in groupings of 3 and 2 letters (i.e., AA or ZZZ). Now, my code works fine but I would like to neaten it up (because I'm …

Member Avatar for TrustyTony
0
245
Member Avatar for kalookakoo

I'm creating a game and I want to incorporate a gif of a running man when the user uses the arrow keys etc. I'm currently trying to use wxpython and I have code that allows it to be played in a small separate window, but I need to know how …

Member Avatar for vegaseat
0
11K
Member Avatar for arick1234

I have an array [x,y] where the values of x is ascending and the y values are random. I would like to sum all of the y values together when the x values are within a certain range. I can't show you any code as i dont even know where …

Member Avatar for Gribouillis
0
2K
Member Avatar for hovestar

I made a program to find primes, but it can't find any prime less that 7(e.g. 2, 3, 5) any ideas? [CODE]import math from math import sqrt x = 1 y = raw_input("What number do you wish to find all the primes below? ") y = int(y) while x < …

Member Avatar for TrustyTony
0
164
Member Avatar for kalookakoo

If I have class variables that are changed as a program runs, and at a certain point I want them all back to default without restarting the whole program, how would I go about it?

Member Avatar for Gribouillis
0
40
Member Avatar for mkmk123

i have list. [CODE]Here is list 1 http://example.com/link1.html http://example.com/link2.html http://example.com/link3.html http://example.com/link4.html +++++++ Funny and Funny Sad and Sad [/CODE] [CODE]Here Is list 2 http://candy.com/link1.html http://candy.com/link2.html http://candy.comlink3.html http://candy.com/link4.html[/CODE] Append list2 into list1 we have result: [CODE]Here is list 1 http://example.com/link1.html http://example.com/link2.html http://example.com/link3.html http://example.com/link4.html Here Is list 2 http://candy.com/link1.html http://candy.com/link2.html http://candy.comlink3.html http://candy.com/link4.html …

Member Avatar for mkmk123
0
271
Member Avatar for StefanieZY

Hi everyone, I need to use python to read some data in my csv file, but the file I have contains 15 rows of introduction in front. all the data I need is from the row 16. I am able to read the data as the way I want it …

Member Avatar for TrustyTony
0
361
Member Avatar for dsmush

Hi trying to recover an RSA encrypted 5 character word using a forward search dictionary attack in Python but having difficulty. The word was encrypted in 2 24 bit blocks (3648141 5604637) padding last block with a space e = 5 n = 21508387 table = {} for ptext in …

0
113
Member Avatar for mwjones

I'm having trouble writing binary data out to a file. My end goal is to add a chunk to a PNG file; which has a format of: length (4 bytes), type (4 bytes), data (lots of bytes), crc32 (4 bytes). Collecting each of these pieces is not a problem, but …

Member Avatar for woooee
0
227
Member Avatar for mwjones

Is it possible to have an optional command-line argument? For example, I want: [CODE]script.py -b[/CODE] to behave differently than [CODE]script.py -b 6[/CODE] In script.py, an enumerated -b argument specifies a behaviour, but if no argument is specified, a behaviour is randomly chosen. Here is my experimentation with getopt. With an …

Member Avatar for Gribouillis
0
235
Member Avatar for tcbenson

Apologies if this is not the place for this but I am looking for a python script that will 1) prompt for csv file 2) read in said csv file 3) count # of rows in said csd 4) for each row in csv, get each column as variable row …

0
42
Member Avatar for draven07

...hello... ..i'm developing a Collection Management System for Student Organizations on our campus using C#...This will be use to track their annual collection activities (cash collection)... ...1 month ago, I succeeded and finally finished this system (yet there are still some bugs that im still working on).. ..Now, I have …

0
54
Member Avatar for kalookakoo

I'm having trouble figuring out how to implement where boundaries are (platforms/landings/ceilings). I have an image running across a background image. When the image gets 3/4 of the way to the canvas, it stops moving and the background image scrolls. Same things going backward at 1/4. So with two different …

Member Avatar for kalookakoo
0
404
Member Avatar for 1337RAM1337

If I make an entry box on a window, then change the coordinates, the box stays put like I want. Now is there a way to set new text in that box after the coordinate change? I can't figure it out for my code

Member Avatar for 1337RAM1337
0
323
Member Avatar for THEPalletizer

Having issues with my English to PigLatin Converter. I can get the code to execute correctly on one word but once i do 2 or more words it adds the first letter [0] + 'ay' to the last word in the line.... any suggestions? [CODE]def main(): # Create a list …

Member Avatar for THEPalletizer
0
394
Member Avatar for theraggamuffin

Hey i'm trying to draw this patch in python 3.2. As you can see I can get it to draw the top row, but I cannot get it to truncate the rectangles at the left and right hand side, and I cannot get it to repeat itself... Please Help :)! …

Member Avatar for theraggamuffin
0
272
Member Avatar for jdm3

Hello everyone, I'm working on an assignment that requires a game that drops multiple objects that need to be caught. I'm using multiple classes and the current one is raising a type error. " File "C:/Users/Joe/Documents/School/I-210/Final/game.py", line 118, in main gift = Present() TypeError: __init__() takes at least 2 arguments …

Member Avatar for jdm3
0
830
Member Avatar for effBlam

How am I able to open the contents of a text file into a GUI with each character in the text being an individual button. Say the text file contains 25 characters that are either "A" or "B" in random order. The text file also have 5 rows with which …

Member Avatar for bawakrbs
0
193
Member Avatar for bellarc

I am attempting to remove instances of a character from a txt file with python using the following code: [CODE]import fileinput for line in fileinput.FileInput("test.txt",inplace=1): line = line.replace("^M","") print line[/CODE] and get the following error: File "par.py", line 6 line = line.replace(" ^ SyntaxError: EOL while scanning string literal I …

Member Avatar for woooee
0
328
Member Avatar for hovestar

I have a problem calling up my compturn() function. Here is my code: [CODE]import random def compturn(): print 'Computer turn:' comp = str(random.randint(1, 9)) if comp == a: compturn() elif comp == b: compturn() elif comp == c: compturn() elif comp == d: compturn() elif comp == e: compturn() elif …

Member Avatar for woooee
0
198
Member Avatar for Sarcasm

Hi, I am starting out with python coding and was looking for some feedback. Constructive Criticism please. Here is my code for game "Word Guess". [CODE] # Word Guess # # Word guess, is a game where the user has five chances to ask # the computer if a certain …

Member Avatar for Sarcasm
0
210
Member Avatar for csterling

I am trying to create a buffer on a shapefile using python's GDAL/OGR module. I'm not sure where to take the code from here...ideally I would like the buffered file to be a new file. All the documentation I found confused me and I thought maybe someone here could help! …

0
62
Member Avatar for slash16

want to do: [ICODE]dict = {'1': ['a'],'2': ['a', 'b', 'c']}[/ICODE] invert it to: [ICODE]inv_dict = {'a':['1','2'],'b':['2'],'c':['2']}[/ICODE] i know the one liner, if the dict was one to one, [ICODE]inverse = dict((d[k], k) for k in d)[/ICODE] can I modify this to work if it was not one to one? My …

Member Avatar for TrustyTony
1
2K

The End.