15,181 Topics

Member Avatar for
Member Avatar for lorayyne

I can't get the math to work in this program. The 'coinflip' flips a coin until it finds either the sequence heads-tails-tails or heads-tails-heads. My issue is that when I run it, the program will perform way more trials than told, and will only account for a random few in …

Member Avatar for woooee
0
195
Member Avatar for faniryharijaona

Hi All, I've got a problem with the python class. I want to create a list of object of type obj() and link them such that the next of one object is the next in its place order. I tried this construction [code] class obj: ------def __init__(self,cargo=None,next=None): ---------------self.next = next …

Member Avatar for faniryharijaona
0
108
Member Avatar for eyewirejets

How do you call a method from the main() from a module to print base class attributes. Objects are contained in a list. Module [CODE] def show_employee(self): print 'Employee Name: ', self.__employee_name print 'Employee Number: ', self.__employee_number [/CODE]

Member Avatar for eyewirejets
0
82
Member Avatar for drfcool

Basically i'm creating a software to calculate the shorting distance between two graphs. I use dictionarys to organize this information I sort the path's as keys , each key has different paths according to the given inputs through the command: PrintByDistance. The inputs are made through the command: `insert:company:City1:City2:Distance` Company …

Member Avatar for faniryharijaona
0
318
Member Avatar for tzushky

Hello, I' ve been having the following problem: - my OS is Centos - I have python 2.4 installed (and several packages in it too, like yum, ...) - I have installed python 2.6 - I have taken out all python2.4 executable references in usr/lib so that only python 2.6 …

0
85
Member Avatar for Undermine

Hello i'm rather new to Python and I was wondering how I could do a menu to prompt the user to choose a number and execute a certain part of code based on his choice. For example: please choose an option 1) 2) 3) then based on users input, it …

Member Avatar for Gribouillis
0
118
Member Avatar for Joe Hart

Hi This is my second post. I am new to python. I hope I have posted my code correctly. I am trying to have Python rewrite the compare.asc file. This file is used with another program called MUST. This is a transmission line program. This program is suppose to compare …

Member Avatar for jlm699
0
405
Member Avatar for nflem

I need helping creating a random number of "hello worlds" import random count = 0 while count < 5: count += 1 print "Hello World" dont know where to put the module

Member Avatar for nflem
0
81
Member Avatar for daviddoria

I usually make a matrix like this [code] from Numeric import * A=zeros([3,3]) print str(A[0,1]) #access an element [/code] I would like to store a pair of values in each element, that is have a matrix where the (0,0) element is (2.3, 2.4), the (0,1) element is (5.6,6.7), etc. Is …

Member Avatar for vegaseat
0
100
Member Avatar for demeryjo

[code=python] import random class gameOfLife(object): def __init__(self, columns, rows, grid = []): self.grid = grid self.columns = columns self.rows = rows for i in range(0,self.rows): sub = ['-'] self.grid.append(sub) for sublist in grid: for i in range(0,self.columns-1): cell = ['-'] sublist.append(cell) def printGrid(self): for sublist in self.grid: print sublist def …

0
48
Member Avatar for dinilkarun

Hi All, I am developing a GUI in Boa Constructor. I am using a grid for displaying some data and want to change the names of the column and row headers in the grid. Please help me in achieving this. Regards, Dinil

Member Avatar for vegaseat
0
104
Member Avatar for harsha_kusam
Member Avatar for action_owl

Can I use python to read the contents of a text file on a server and dynamically update text on a web page(based on the text in that file)? This is something that I need to accomplish but I'm not sure if python is capable or if I should be …

Member Avatar for vidaj
0
141
Member Avatar for bhanu1225

hi every one. import os from reportlab.pdfgen import canvas from reportlab.lib.units import cm c = canvas.Canvas("/Users/venkatarampey/preview.pdf") c.drawString(8*cm, 28*cm,"HELLO PYTHON") c.showPage() c.save() FILE = open("/Users/venkatarampey/preview.pdf","r") The is the python script for previewing a pdf when run. Problem here is , i was able 2 generate a pdf on mentioned path but …

0
46
Member Avatar for dinilkarun

Hi All, I would like to create new rows dynamically. When a user clicks a button, a new row should be added in the grid. Please guide me as to how can I achieve this. Thanks, Dinil

Member Avatar for lllllIllIlllI
0
92
Member Avatar for EvanPM

Ok, Is there an easy way to do this: I want to take a string and convert it to a binary string with base of my choice and convert it back. So base 2 would be 1's and 0's, etc. example: [CODE=syntax] in_string = "testing" binary_string = string2binary(in_string, base = …

Member Avatar for vidaj
0
148
Member Avatar for lorayyne

Hi all, This is a problem that has been holding me up for a while in Python. I frequently get issues relating to "global ___ is not defined" and cannot figure out what I'm doing wrong. Here is a coin-flip function I wrote: [code] def coinflip(): import random import time …

Member Avatar for targ
0
212
Member Avatar for Undermine

hi, im trying to learn python and this is giving me [ICODE]>>> x=input("Enter a value: ") if x % 2 ==0: print ("even") else: print ("odd")[/ICODE] then when i execute: Enter a number: then i enter a number but it does not print even or odd. why?

Member Avatar for Undermine
0
78
Member Avatar for Vihaio2012

Hello, I want to total up a variable that changes every time a function is run. [code]import random def flip(): h,t = 0,1 cheads, ctails, = 0,0 cflips = random.choice((0,1)) if cflips == 0: cheads += 1 return 'h' else: ctails += 1 return 't' def repeat(f,n): for i in …

Member Avatar for vegaseat
0
110
Member Avatar for lorayyne

Hello, I am trying to write a program that flips a coin until it gets the sequence "heads tails heads" and then stops and says how many flips it took to get that sequence. This is what I have so far: [code]import random import time import string def coinflip(): heads …

Member Avatar for lorayyne
0
150
Member Avatar for nonang

How do I have the algorithm below to sort my list in opposite direction (right to left) instead of left to right. Also, how do I make it sort simultaneously or alternatively in both directions? Thanks. [code=python] def bubblesort(l): for passes in range(len(l)-1, 0, -1): for index in range(passes): if …

Member Avatar for vegaseat
0
159
Member Avatar for happymadman

Is there anyway to compare lists or check to see how many of the objects in one list are the same as the other list? eg: L1 = [dog, cat, john, moo] L2 = [dog, cow, moo, stuff] there is two of the same "things" in it I'm trying to …

Member Avatar for happymadman
0
145
Member Avatar for Vihaio2012

Hello, I'm trying to write a coin-flipping program. I can get the program to produce a random coin flip result (represented as either "h" or "t") but I want to add the individual result to an ever expanding string. For example, the first result would be "h" and the big …

Member Avatar for scru
0
107
Member Avatar for besktrap

hi everyone! I have two files, main.py and sprite_class.py. sprite_class.py is in a separate folder called lib. here's a quick diagram: ------------------------------------ /folder engine/ main.py /folder lib/ sprite_class.py ------------------------------------ ...sprite_class.py contains a class called Sprite: [CODE] # sprite class class Sprite(): def __init__( self, start_x, start_y, image_path ): self.x = …

Member Avatar for besktrap
0
10K
Member Avatar for leegeorg07

hi again i want to make something that captures images of my window and sove them into either a gif file or a video file, i thought about using win32s [code] win32gui.GetDesktopWindow() [/code] but i wasnt sure how to use this to save it to the file how could i …

Member Avatar for jworld2
0
107
Member Avatar for 136456

Hi every bod y I am new in programming and I like to start with pyqt but I can not find anything for learning in internet please help me how how can I write program with gt designer & when I make a form in qt how can it work(my …

Member Avatar for Ibn Saeed
0
266
Member Avatar for Dart82

Hello, Im currently writing code for a program that translates a line of text from English into German then back again. Its a big loop that needs to be executed the same number of times as words in the text. I'm almost there but there doesn't seem to be anything …

Member Avatar for Dart82
0
94
Member Avatar for gbrokaw

Hey everyone, I'm writing a program with a Tkinter GUI for my job and I was wondering whether there is a way to create an icon on my desktop to start it so I don't have to start Idle and run the program from that (computer un-savvy people will need …

Member Avatar for gbrokaw
0
135
Member Avatar for apollo1492

Im writing this program that draws a bar graph showing an investment growth. and this error keeps coming up and i cant figure it out. this is the syntax that python keeps telling me. Traceback (most recent call last): File "C:\Python26\lala.py", line 68, in <module> main() File "C:\Python26\lala.py", line 47, …

Member Avatar for apollo1492
0
137
Member Avatar for jwatte

I am embedding Python 3.0.1 on Windows, using MSVC 2008 sp1. I do not pass FILE* structs to Python, so I think compiler version differences is not a problem. The following code has a problem, in that the "txt" string that comes out at the end only contains the character …

Member Avatar for jwatte
0
356

The End.