15,175 Topics

Member Avatar for
Member Avatar for aleezy

For my final project our group is suppose to simulate a game of table tennis this is what we have so far at the bottom. We followed the raquetball game setup for the code but we werent sure how to change this so that when a player scores it doesnt …

Member Avatar for masterofpuppets
0
2K
Member Avatar for lewashby

Please look at the program below as well as my understanding of how it flows and correct me if I'M wrong. Thanks The first line in main - [COLOR="Red"]crit = Critter("Poochie")[/COLOR], creates an object with the string "Poochie" and autmoatically calls [COLOR="Red"]__init__[/COLOR], printing "A new critter has been born!" [COLOR="Red"]__init__ …

Member Avatar for lewashby
0
172
Member Avatar for nizbit

I have a dictionary that I would like to load from a file into a class variable. The dictionary holds configuration data. I would have different files for different configurations. I was wondering if there is a way to do this? I found pickle but that saves an existing instance …

Member Avatar for winmic
0
88
Member Avatar for saikeraku

I'm just trying to create a program that will remove all the trailing whitespace in a text file. (Like all the whitespace after each sentence for the whole text file.) [CODE] n = raw_input("Enter name of file: ") f = file(n, "r") fr = f.read() for fr in f: fr …

Member Avatar for woooee
0
128
Member Avatar for J0kerman

So i want to define a variable with the index of a current step, and then print that variable. For example I have a loop with 10 steps, and i want to define 10 variable: x1, x2, x3....x10 and then print them out: x1=something, x2=something, ......, x10=something.Does anyone know how …

Member Avatar for J0kerman
0
23K
Member Avatar for gangster88

how could i double a number when clicked on in the graphics window?... this is for graphics.py and a line separating the two sides in the graphics window and on each click on either side it must go up by 2 until 12? i can only think of using a …

Member Avatar for jaison2
0
151
Member Avatar for sneek

Hi, may anybody tell me why there is a init AND a new-method? Why not using one constructor-method like we have to use in java and other OO-lanuages?? Would be nice if somebody can give me an idea about that. Thanks a lot Jonny

Member Avatar for sneek
0
175
Member Avatar for deonbannes09

I'm suppose to make a program that uses a Card class to simulate the random dealing of a single Blackjack hand by a Blackjack dealer who follows the standard rules. As it simulates the the single hand, it should randomly draw a new card (by randomly choosing a suit and …

0
37
Member Avatar for lewashby

I have to prgrams and thus, two question to ask. In the following program how does the line [COLOR="Red"]status = staticmethod(status)[/COLOR] do anything? My python programming book somehow connects it to the line [COLOR="Red"]Critter.total +=[/COLOR] 1 but I don't see how? Please explain. [CODE]# Classy Critter # Demonstrates class attributes …

Member Avatar for vegaseat
0
191
Member Avatar for ffs82defxp

i recently found that variables set in a function cannot be used in another function. so to make variables 'universal' i have to make them global variables? and you do that buy stating them global, like this? [CODE]global [VARIABLE NAME]=[VALUE][/CODE] i have a feeling there is more to it.

Member Avatar for vegaseat
0
378
Member Avatar for ffs82defxp

is there a command or fuction in python that deals with email? like: [CODE]email(ibmceo@ibm.com, 'Hello, my name is Bill. How are you doing at IBM?', email.cc(),attach("C:\123321.txt"))[/CODE] :D

Member Avatar for vegaseat
0
83
Member Avatar for jaison2

I need help with the function but i have no clue how to?.. the function should generate a random number between 1 and 100 and then allow the user to guess the number. After each guess it should display if the guess is too high or low and if they …

Member Avatar for snippsat
0
206
Member Avatar for NicholasE

Dear members, I need to write a small loop to generate the following: 0 0 0 0 .... 0 1 1 1 .... 1 2 2 .... 2 3 .... 3 4 : 299 I think it needs a double loop but since i am still beginner in python i …

Member Avatar for NicholasE
0
109
Member Avatar for ffs82defxp

simple simple grrr [CODE]import math import time while 1: r = input("Enter Circle Radius --> ") circ = (pow(r,2)) * 3.14 print '' print 'The circumferance of a circle with a radius of ',r,'is',circ,'.' print '' time.sleep(2) print '' print '' print '' print "Loop Start or Exit? 'l' or …

Member Avatar for masterofpuppets
0
116
Member Avatar for SoulMazer

So, I have a script that needs to "clean up" when it is exited: it needs to clear a special logging file and other small things that affect the next startup of the script. The script has a GUI written in Tkinter, if that is relevant at all. Is there …

Member Avatar for SoulMazer
0
100
Member Avatar for willygstyle

Hello all, I have been trying for a few days now and done quite a bit of reasearch on the internet and this website to find out how I can authenicate to a website. It could very well be that this particualar web server is picky I'm not to sure. …

Member Avatar for willygstyle
0
181
Member Avatar for coffeebox

I am beginning to work on the GUI for a project I have been working on for several weeks now. I would like the application to end up being cross platform, and I prefer not to have to manually code the whole GUI so I decided to work with BoaC …

0
46
Member Avatar for MRWIGGLES

Hi, I'm having trouble just printing particular strings out of a sentence. <h1>hi my name is</h1> if i just want the program to print out <h1> </h1> and ignoring the text in between, how would i do that? i have tried converting everything to ascii and printing within the range, …

Member Avatar for MRWIGGLES
0
92
Member Avatar for vsagarmb

i am not able to figure out why python throws an error when i call this function. In the code snippet below when i call set_greyLevel() python throws an error. If i comment the function call it works fine. Please help. Thanks in advance. [code=python] def set_greyLevel(self, grayScale): if grayScale …

Member Avatar for willygstyle
0
163
Member Avatar for maomaohui

i got some homework for a program in python [CODE]''' Function that haven't been achieved. ============================================ Maxium Number. No number bigger than 2147483648 or less than -2147483648; Proper 'd' function - Accept the result or only input. - Proper 'd' substitution calculate. .Gets the function of '=' .Has it's own …

Member Avatar for Ene Uran
-2
72
Member Avatar for roshini.johri

hey i am a beginner as far as python is concerned..i am having diff in understanding this code..i am supp to do it in python..if anyone can tell me wht it does it wud be really helpful [code] for qid,query in "as2.qrys": for word in query: docs = set(index[word]) for …

Member Avatar for Ene Uran
0
133
Member Avatar for gangster88

how could i call the above function so that when i input something like 21 for the mark the ouput is "the grade is A", and when the user inputs something more than 25 and less than 0 hes asked to input it again..? [code] def mark2Grade(mark): if mark >=20: …

Member Avatar for gangster88
0
115
Member Avatar for paat

Hi, I'm trying to get last inserted row id from cursor object but no luck. Any Ideas? [CODE] import pgdb conn = pgdb.connect(None, 'postgres', None, '10.58.5.50', 'dpd') cursor = conn.cursor() cursor.execute("INSERT INTO ops.tbl_returnlist (rname) VALUES ('Test')") conn.commit() print cursor.lastrowid [/CODE] Outputs None

0
35
Member Avatar for ShadyTyrant

I am working on a library database module ([URL="http://www.daniweb.com/forums/thread241506.html"]See this thread[/URL]). I want to implement a custom error class. [CODE=Python] class LibraryError(Exception): def __init__(self, value): self.parameter = value def __str__(self): return repr(self.parameter) [/CODE] This class needs to handle errors such as sql execute errors, and be able to check for …

Member Avatar for ShadyTyrant
0
85
Member Avatar for thesinik

Alright so I want to write a program that will compute trig functions (sin, cos, tan, arcsin, etc.). Basically I'm ignoring the included math library in python and hard coding it myself. My issue is that I'm fairly new to programming and not sure how to go about coding a …

Member Avatar for thesinik
0
4K
Member Avatar for Yeen

I understand the basic principle of recursion, but I'm having trouble implementing it in practice. I understand this first case perfectly fine. It works because n is constantly getting closer to 0. [CODE]def faculty(n): # Base case if n == 0: return 1 # Recursive call else: return n * …

Member Avatar for Ene Uran
0
121
Member Avatar for SoulMazer

Okay, so I'm having a little trouble. Let's say I run "scriptA.py" and it has a GUI (Tkinter) and it is running in its mainloop. I want to create a "scriptB.py" that can end "scriptA.py"; would there be a way to do this regardless of the OS it is on …

Member Avatar for SoulMazer
0
267
Member Avatar for lewashby

In the following program I don't understand the [COLOR="Green"]staticmethod[/COLOR] or what is has to do with [COLOR="Green"]Critter.total[/COLOR]. From what I can see, total is a class attribute and [COLOR="Green"]Critter.total[/COLOR] is accessed from the [COLOR="Green"]__init__[/COLOR] constructor method. Thanks for any and all replies. [CODE]# Classy Critter # Demonstrates class attributes and …

0
64
Member Avatar for ffs82defxp

Its not running [CODE]import math import os cls = os.system("cls") title = os.system("title Pythagorean Theorum Solver") def MainLoop(): cls print "Enter 3 coordinate plane points (x - y) format" print "" firstPair = input("--> ") SecondPair = input("--> ") MathPart() def MathPart(): '''structure of the formula: squareRoot of --> (x-y)^2 …

Member Avatar for vegaseat
0
140
Member Avatar for ShadyTyrant

I am designing a module to perform some actions for a library database application. The methods are not implemented yet but I was wondering what you all think about nested classes in this situation. Design One [CODE=Python] #!/usr/bin/env python # File: .py # Author: shadytyrant@gmail.com # Date: 2009-11-25 # Notes: …

Member Avatar for ShadyTyrant
2
258

The End.