- Strength to Increase Rep
- +7
- Strength to Decrease Rep
- -1
- Upvotes Received
- 10
- Posts with Upvotes
- 10
- Upvoting Members
- 7
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
Hello. I was wondering if anyone could help me with a caesar cipher program I am attempting to create. I was asked to write a caesar cipher encoder program. Ok. No problem. This is what i got: [code] import string def main(): print "This program will encode your messages using … |
|
I asked that in another thread, but it got lost: [QUOTE]When do you use root.quit() and when do you use root.destroy() to exit a Tkinter program?[/QUOTE] Also, can you intercept an exit when you use the little x in the title bar, just to affirm that you really want to … |
|
When I run: [code]dec = 255 print hex(dec) [/code]I get 0xff, but I like to get just 'ff' |
|
Hi, I have two list of any datatype supported by python. I want to check whether the any of the element of first list is present in second list or not. Example: I have a = [4,5,6] b = [1,3,8,6,7,9] I want to check whether any element of a is … |
|
I need a function that returns True or False if an integer n is a prime. Any 'high speed' thoughts? |
|
Greetings to Everyone :cool: , I just would like to know how to run/launch/start the IDLE ide of python in linux? (In windows the IDLE ide comes part of the python download, I assume its the same for linux??! or not?!) I currently have installed ubuntu linux, its already got … |
|
I have another string dilemma. I am asked to write a program that counts the number of words in a sentence entered by the user. This is what I have right now, although I don't think that it is anywhere near being correct: [code] import string def main(): print "This … |
|
search(l, key): if len(l) == 0: return False elif l[0] == key: return True else: return search(l[1:], key) I was just wondering if there is any way that i can get rid of "elif" statement. The function is suppose to return False if the key is not in the list … |
|
How would you make a simple bar graph from a list of data? [code]data = [20, 15, 10, 7, 5, 4, 3, 2, 1, 1, 0] [/code] |
|
im confused with [I]__call__() [/I] method defined within the class. [I]__init__() [/I] is used as constructor, and is called when we create an instance of the object. when does [I]__call__() [/I] method get called even though we not specify it explicitly... please help.......... |
|
Hello everyone, I just started to learn how to program in Ruby. It is a pretty cool language. You can get ruby from [url="http://www.ruby-lang.org"]www.ruby-lang.org[/url]. You can see my code snippets on making widgets using fxRuby (fxRuby is downloaded seperatly from ruby, unless you get the one click installer, which installs … |
|
|
So, I created this fun little Tic Tac Toe game all on my own. It was a tough project, and I know I used some inefficient strategies in the coding. Just like the other things I've posted, this could use a lot of suggestions in the areas of clean code … |
The name says it all, I think. You have a nested list, you want to flatten it (e.g. because you want to count the occurence of an element), this function is all you need ;) |
|
[code=python]from random import randrange import math def main(): print "This program will simulate the probability of rolling " print " a 5 of a knid in one throw." pos = randrange(1,7) dice = [0] *5 value = dice [ : ] for pos in [0,1,2,3,4]: dice[pos] = randrange(1,7) roll = … |
|
This demonstration was originally proposed to be posted as a Python tutorial but with further inspection it was deemed more of a "how-to" guide, in this case, how-to create simple animation via Tkinter (Tool Kit Interface) All the necessary elements are included in the attched zip file. This includes: [LIST] … |
|
Ok, so from my last post, you might have figured that I'm making a coder/decoder package. Anyways, say I've got a string of letters that i want to decode, such as: AAAGGGCCC Which should produce: ACB Because a=aaa c=ggg and b=ccc Currently with my program, you have to input one … |
|
Hi to all, after two months I decided to give Python one more chance. Here is a little code snippet about counting number of words in text file. (Under word I assume any combination of letters and numbers delimited by standard separators " .,\n\t" [code] file = open ( "Test.txt", … |
|
I have to write a script called trying. The script takes a full path (like /users4/st/jdoe/prog.c) as an argument and displays the path and the file name. For /users4/st/jdoe/prog.c, the path is /users4/st/jdoe and the file name is prog.c. I know that I can use grep for it, but it's … |
|
I want to make a small Molecular Weight calculator. If the user for instance enters the molecular formula for dichloro-benzoic acid as "C6H3Cl2COOH", I would like to split it into a list like ['C6', 'H3', 'Cl2', 'C', 'O', 'O', 'H'] so I can then combine all the carbons, chlorines, oxygens … |
|
With my program, I have been trying to simulate the game of Roulette (at a casino) with a GUI, but I have a problem that I can't seem to figure out. For some reason, any kind of accumulator for "current funds" I place in the program doesn't seem to work … |
|
Things are getting quiet around the shop, seems like all the coding is done in foreign lands. Any way, let's get a thread started, a multilingual coding spree showing how to display "Hello World! (computer language used)". The code has to be a full program! Make sure you have the … |
|
Hi, I'm having trouble removing objects from a list. It seems that when I remove single objects in a loop, the loop kind of skips elements in the list, not continuing from the point where the last removal occurred. I want to remove only certain elements from a list, and … |
|
G'day, Thanks Mr. Vegaseat, Jeff, Ene, Mawe for all of your great help so far...I'm slowly (very slowly!) getting used to Tkinter. But I'm again puzzled by how Tkinter does things. Some examples of code at the beginning say "from Tkinter import *" and some say "import Tkinter as tk" … |
|
I read somewhere about somebody importing the sys.py module. I can't find the bugger on my system! I have python 2.5.1 installed on this Waxows XP machine. I did a search for sys.py in the c:\python25 folder and sys.py isn't there! Isn't it supposed to be installed by default? If … |
|
I would like to be able to add the day, month and year to the end of the filename. I plan on running a version of this script every day so I would like it to create a new file each day. I would like the file to look like … |
|
[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 |
|
so when i run this in python interpiter it works [CODE] >>> import os >>> b= os.path.getsize("/path/isa_005.mp3") >>> b 2071611L >>> [/CODE] but when i run it in a script [CODE] b= os.path.getsize("/path/isa_005.mp3") FILE.writelines(b) [/CODE] i get an error. any one know how i can get it to print the … |
|
This function is part of a program to convert numbers between different bases. [code=language] num = 32 b1 = 10 b2 = 2 x = 1 def increasex(num,b2,x): if num%(b2**x) < num: x = x+1 increasex(num, b2, x) else: print x return x print increasex(num,b2,x) [/code] The parameters are the … |
|
hi i am reading from a file and grep'ng for some values and writing those into another file I am using "|" as a seperator for the values smthing like this printf FILE " %d| %d |%d\n",$x,$y,$z; In file i am getting values like this 12|23|23 123|3|234 22333|223|3 but i … |
|
I was wondering if there is something in python similar to the begin expression in Scheme, and if not how would you write something in python to simulate it. |