- Upvotes Received
- 6
- Posts with Upvotes
- 6
- Upvoting Members
- 4
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
42 Posted Topics
Re: Many years ago I was browsing for 'free' software. I ran across a download for an entire OS called Knoppix. I burned it to a live-cd and played with it for a while. Not knowing much at all about computers and even less about Linux, I never actually installed it … | |
I've been going through a couple of tutorials on SDL and having moderate success. But this one has me stumped. The tutorial from LazyFoo.com has me creating a dot that emits sparks. I followed along and wrote my code which returns my .bmp as NULL. Hmmm, I must have done … | |
In the book "How to Think Like A Computer Scientist" on the website openbookproject.net the tutorial leads you to draw a house with a pre-written script. It then instructs you to: # Wrap the house code in a function named draw_house(). # Run the script now. Do you see a … | |
Re: [QUOTE=tonyjv;1537673]Your indention is off, for other things I can not help as you do not explain your problem.[/QUOTE] I think it's just a code snippet. Gives me some ideas for retrieving movies from my camcorder though. | |
Re: In Ubuntu, root is indeed uid 0. Did you try executing your script as root? or did you leave it to python to elevate your privileges? You can just prompt the user to run your script as root: [CODE] user = os.getuid() if user != 0: print "This program requires … | |
Re: Why do you have to use Notepad? Couldn't you just create a text file? [CODE] x = 1 while x < 3: file_name = "named %s" %x out_file = open(file_name, "w") out_file.write("Test\n") out_file.close() x += 1 [/CODE] | |
Re: Do you have to use if/else statements? A switch would better serve your needs. If you must use if/else, don't try to pass a condition to the else statement. 'else' will execute if the 'if' is false. So an if/else should look similar to [CODE]if(condition) { do this} else { … | |
Re: [QUOTE]# if ((nights<=30) && (nights!=0)) // response can not be more than 30 or less than 0[/QUOTE] Or else what? where's your else statement? (nights != 0) does not restrict to positive integers either. How about (nights > 0). Then an else statement to return 1 or just print an … | |
Re: Why not just convert to all ASCII first. Not sure how to do '67', but the unsorted array would look like [65, (67 in ASCII), 57, 48, 66, 68]. Then sort it with your int sorter and convert back. The 2+ digit numbers might be a problem, but a function … | |
Re: I actually read Learn C++ in 21 days. It was one of about 4 books I used to teach myself C++. Without naming the other books, 21 Days was the most helpful and seemed to cover more than the others. I also found myself a medium sized project to put … | |
Re: [CODE]# void PrintArray(int* array, int n)[/CODE] This is an argument for a single dimension array. How did you declare your array? [CODE]int array[SIZE][2];[/CODE] Maybe that's how your function should see it too. Try [CODE]void PrintArray(int* array[][2], int n)[/CODE] The first dimension can be blank and the compiler will fill it … | |
I found an old post (2002) on another website where someone asked how to colorize text in Linux. The reply was: [CODE]printf ("\033[31ma\033[32mb\n");[/CODE] Where the format is "\033[XXm" followed by the text to be colored. I tried this on my Ubunutu machine and it works. It even works with "cout … | |
I am completely new to C++. I have a function that deals cards for a blackjack game. To do this, I need to call this function 10 times (two cards each for 4 players and a dealer). But it just deals the same card to everyone. I think it might … | |
I am trying to learn C++ through on-line tutorials and such. In almost all tutorials, the author tells you which headers to include for that particular exercise, but never tells you how he knows that. I understand that if you are advanced enough to be writing tutorials, you know off … | |
My daughter plays FaceBook games and is always asking me to solve anagrams. So I thought I would make a script for her to enter a scrambled word and it would compare it to the built-in spell check dictionary. But this code returns words such as quip and quiz when … | |
My rand() isn't very random. As a matter of fact, it's not random at all! I am running Ubuntu 10.04 on both home comp and laptop. When I execute the code: [CODE]#include <iostream> #include <cstdlib> using namespace std; int main() { int x; x = rand(); cout << x; return … | |
I thought I could organize my movie files by writing a quick and dirty HTML script for them. I read a few tutorials on HTML (not CSS) and it seemed simple enough. So I made this: [CODE]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" id="DocumentRoot"> <head> <title>Media</title> <meta … | |
Re: Have you tried singling out the first character of the filename? For example: [CODE]#!c:/Python31/python.exe -u import os path = "C:\\test\\com.comp.hw.prod.proj.war\\bin" for dirpath, dirs, files in os.walk(path): print (dirpath) print (dirs) print (files) for filename in files: [B]if filename[0] != ".":[/B] print ("filename " + filename) print (dirs) if "^.*" in … | |
Re: You have already stated that you are a newbie. Maybe it's time to admit that you are still a little TOO new for this problem. Go back to the tutorials and learn file manipulation. How to open and read a file (as a list), and how to write to a … | |
I have an old computer that doesn't have internet access. It does have Python 2.6 which supposedly has Tkinter. The problem is, it returns an error that Tkinter module is not installed. I searched the net, and saw that I may have to manually install tcl/tk. Done. I tried [CODE]import … | |
Re: Or keep it simple: [CODE] if "@" not in mail_input: print "There is no '@' symbol!" [/CODE] | |
Re: I don't do Windows either, but you could simply use a variable as a bool. Try: [CODE] result = tkMessageBox.askyesno(title='Invitation', message =text) if result: print 'Invitation accepted.' [/CODE] I just ran into a problem with a Tkinter gui I've been working on my laptop. The above format worked on my … | |
Re: You didn't by any chance name this "string.py" did you? I was testing your code, and without thinking, named it "string.py". This is the name of an important module called automatically from python. If you have another with the same name, string.py can't find the substring() func it needs for … | |
![]() | Re: Look at line 11 of costAd(). You called it in your module without an argument. ![]() |
I am trying to put a terminal into my tk gui program as a widget. I figured out how to have the output of a command sent to a text widget: [CODE] root = Tkinter.Tk() tfield = Tkinter.Text(root) tfield.pack() for line in os.popen("run_command", 'r'): tfield.insert("end", line) root.mainloop() [/CODE] But how … | |
So I have figured out how to receive output from an application using [CODE]process = subprocess.Popen("my_app", shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE) info = process.communicate() [/CODE] But how do I SEND info TO an app? I have an application that asks for a yes(y) or no(n) confirmation … | |
How would I execute a command and have it's output returned as a list or string? For example (in Linux): [CODE]os.system("iwconfig")[/CODE] prints a list of wireless devices to stdout. How can I make Python see those results as a list or string so I can search for certain devices (like … | |
Re: You could assign numbers as responses. Like press 1 to hit and 0 to stay. [CODE] def call(): stand = input("Press '1' to STAY or '0' to HIT") if stand == 1: do something elif stand == 0: do something else else: call() [/CODE] | |
Re: This will look through your file for the word "DATA". It will print the index (location) of your word. Now you need to write a code to work with your file starting at that index number. If, for example, this returns/prints 38, then you will need to iterate through the … | |
I wrote a script (kind of a learning thing) to open .rar archived files using unrar (non-free) in Linux. Now I want to add a section where my script will check to see if unrar is installed. To complicate matters, Linux also has a package 'unrar-free', and both use the … | |
Re: I think the idea of an Open Source project on this thread is a great one! It would give some of us an opportunity to see how these things work, and maybe even learn a thing or two along the way. May I suggest also a periodic posting of the … | |
Re: Try this: [CODE] is_lucky = False # a boolean value set to False lucky = raw_input("Please enter an integer: ") # Notice only one set of parenthesis for i in range(len(lucky)): if lucky[i] == "7": is_lucky = True else: pass if is_lucky: print "%d is lucky!" % int(lucky) else: print … | |
I am making a poker game using pyGTK. My problem right now is that the other players won't let me play! Each player has a function for betting and they go in order such as amandaBet(), playerBet(), billBet()... where player is you. Since this is a GUI game, I am … | |
I have written a poker game in Python and have it fairly well finished. My hang-up now is an option to play again. Most of the game is in a function called playHand() which re-runs as long as you still have money, but if you lose all of your money, … | |
Re: Use a remainder modulator: while 1: print ("C" + '\t' +"F") celsius = 0 for celsius in range(0, 101): fahrenheit = 1.8 * celsius + 32 if celsius % 2 == 0: print ('%0.2f %0.2f' % (celsius,fahrenheit)) else: pass answer = input("\nWould you like to run this program again? y/n\n") … | |
I am fairly new to Python, but trying to make a poker game. How do I determine the winner? I have 'scored' the hands 1-8, and given sub-scores for the high card, but how do I compare the scores of 4 players and then in the event of a tie, … | |
Re: This is rather crude, but it works: [CODE= python] import random y = 0 count = 0 even_count = 0 odd_count = 0 while count < 100: x = random.randint(1,101) print x y += x count += 1 avg = y / count if y %2 == 0: even_count += … | |
If I have a list of 5 random integers, is there a simple way to iterate through the list and see how many of each number there are without using 25 if/elif statements. For example my list might contain [3, 7, 10, 10, 14]. How would I determine that there … | |
I am trying to order a list containing integers. I want them sorted in numerical order from lowest to highest. I tried using sort but got the list baxk exactly as it was. [code=python] x = [5, 3, 7] x.sort print x [/CODE] What command would I usr to make … | |
I am working on a function to find the slope of a line if given x1, y1 and x2, y2. Not too hard. But I need the results to be floating point not integers even though the x and y inputs are integers. I have : [code=python] def slope(x1, y1, … | |
I have an assignment to: "Wrap this code in a function called compare(x, y). Call compare three times: one each where the first argument is less than, greater than, and equal to the second argument." So I came up with this: [code=syntax] def compare(x, y): if x < y: print … | |
I am trying to learn Python. I have browsed through a few tutorials and tried to follow them until they get too complex and I try to find another one to give a different perspective. I am currently trying (and very much enjoying) the very basic "How to Think Like … |
The End.