- Upvotes Received
- 1
- Posts with Upvotes
- 1
- Upvoting Members
- 1
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
- Interests
- Programming
- PC Specs
- Core 2 Duo E6600 2 Gig Ram Radeon x1950 XTX Seagate 750 Gig HDD
In the last couple of threads people have used the Python class, but really don't seem to know how to use them properly, or why to use them. Hence my question: "Why would you use a class in Python?" I though only Java forces you to use OOP. |
|
The idea of this thread is to help the beginning Python programmer with hints and helpful code. Please feel free to contribute! If you have any questions start your own thread! The creators of Python are very active, improving the language all the time. Here is a little of the … |
|
Does anyone know an easy way to do array's of arrays? I'm not 100% sure this is the thing I want though because I just need a simple way to make a loop able to change the list it's comparing. I have the loop done, I just can't figure out … |
|
Ever have two lists in python and you want to know what how much of one list the other contains? This code snippet will help you do that. |
|
Hi there, hope someone can help, I was just wondering WHERE it is possible to get such an adapter (i think they are VGA adapters) as I have mentioned above, one that will at least connect ur monitor to your PS2 so that you can use it as TV. I … |
|
I'm using Windows XP. I got a new flash disk and I used it outside in an internet cafe. When I got home, there was this weird file that suddenly popped out so I supposed that it was a virus or some malicious file because I haven't seen it before. … |
|
If I print something to the screen, is it at all possible to erase some of that? Some sort of backspace? That way it would be possible to clear the screen, make a text progress bar, etc. If not, what's the easiest way to do something similar? Thanks, |
|
My Dell laptop is saying"Primary harddrive disk 0 not found No bootable devices-strike F1 to retry boot F12 for set up utility" and is making a clicking noise. On the set up page it says "Bios version A20" and "Latitude C600"(not sure if that info matters,very new to computers) Please … |
|
I need a way to get a number from the user, break that number up (eg. 1128 into 1 1 2 and 8), and then manipulate each number. Here is what I tried to do, failed horribly: [code]#include <iostream> #include <string> #include <cmath> int main() { string str; int a … |
|
Can someone look at this and tell me if it actually is doing what it's supposed to. [php]from __future__ import division counter = 1 while True: li = [] for i in range(1,(counter+1)): if (counter/i) % 1 == 0: li.append(i) if len(li) <= 2: print counter,"is a prime." counter = … |
|
In my program I have a loop with a variable that shows the players name, they choose something then it goes back to display their name and all it shows is arrows.... why? I'll post my code, run it and enter 3 or 4 players are playing, give them some … |
|
I was wondering how I could access my several countryAttachedXX arrays(in this post they start on line 85), without many if statements, determined by user input. I was thinking maybe an array of arrays, but had difficulty finding out how to do that on the web. Thanks, -Matt [code=cplusplus]/**************************** * … |
|
I am trying to make a text version of risk, and I need to store the population, or army count, for each country. So the only way I could think to do that, as you'll see in my code, is by making a variable for each country, and then storing … |
|
How do you initialize an STL list with the values when you declare it? That way I don't have to add the values later with a loop and push_back. Thanks, -Matt |
|
I'm having some trouble with STL lists. What I want to do in my program is take the players initial and put it into an array at the spot that they got from when I divided up 20 numbers (0-19). Can anyone tell me why line 151 (in this post … |
|
I'm wondering why it prints so many spaces when I only ask it to print one. Here's the code: [code=cplusplus]#include <iostream> #include <string> using namespace std; string ar[21] = " "; int main() { ar[3] = "M"; ar[4] = "n"; for(unsigned int i=0 ; i<20 ; i++) { cout << … |
|
I had a thread going not too long ago, and from that I was able to make a global vector that I can store class objects in. But now when I try to access it, it says "no match for 'operator[]' in 'jailHouse[0]' " Anyways, Here's the code, if you … |
|
How can I make a pointer to an array? So that I access the members of the array by using the pointer in a seperate function. I'm wondering because I have an array I have to access in functions other than the one it was defined in, but I need … |
|
I'm making a program where there is a function that asks how many players there are, and depending on the answer, it makes an array of classes that size. How can I access the array of classes from other functions? I thought I would just make it global, but how … |
|
I need to set up 2 buttons to take input from the user, that increase and decrease a variable, it doesn't matter which 2 buttons are used, but preferably the up and down arrows. And I also need to have a display of the variable that constantly updates as it … |
|
Is there a way to make a loop that creates strings? I ask the user how many players there are, and then the loop makes that many strings in order to get all of their names... Something like this, (but not in normal english...): [code]cout << "How many players? " … |
|
Can anyone tell me why this doesn't work? I know it's probably really easy, but I did try.... [code]/* ISU program created by Matt in grade 12 programming. */ #include <iostream> #include <list> #include <iterator> using namespace std; class humanPlayer { public: humanPlayer(char thePlayersName, unsigned int thePlayersTurnNum); //constructor ~humanPlayer(){}; void … |
|
When using an STL list, how can I check if a certain variable happens to just be in there? Basically, given this already: [code]#include <iostream> #include <list> #include <iterator> using namespace std; list<int> integer_list;[/code] I need a way to code this in C++: [code]if(x is in integer_list){ do this }[/code] |
|
**I know the code looks big, but it's a very small isolated section at the bottom (starting at line 164) that's giving me the problem.** When this program is run, when I try to open the file I just appended some text to, it doesn't open... can anyone spot why? … |
|
|
I know printing primes isn't anything new, but (like always) I'd love to hear some feedback on how I can make my code more efficient and other constructive criticism. [php] def print_primes(r=10): primes = [ ] for i in range(2,r+1): prime = 1 for divisor in range(2,i): if i % … |
[code]str1 = 'c:\documents and settings\user\desktop' str2 = 'starcraft.exe' print str1[/code] I would like to know how it would be possible to add str2 to the end of str1 with a "\" inbetween the two strings. so that I end up with "c:\documents and settings\user\desktop\starcraft.exe". Thanks |
|
[code]############################################################################ # # # This program seeks out every copy of "starcraft.exe" in the computer # # and deletes them. # # Created by Matt in Python 2.5 May 2007. # # # ############################################################################ import os def file_find(folder): """search for a filename fname starting in folder""" for root, dirs, files … |
|
Ok, so I'm making a program in c++ that keeps track of the number of objects you make for a specific class. It works, but I added a part to change the screen output at a specific number of objects and that's where it broke.... heres the program: [code]#include <iostream.h> … |
|
Hey, I was just wondering how to get a variable assigned a random number within a certain range. I tried the rand, but I seem to get the same set of numbers everytime I run the code... I did some research on random numbers in C++ and understand the whole … |
|
Hi. I'm currently working on a program that requires me to use arrays. Does anyone know a good tutoring site that I can go to?? Thanks! |