15,175 Topics
| |
why does this gives error `print "module {0}".format(key)` , i hope this is nt the python version problem... | |
A permutation is the arrangement of a set of items in different order. One interesting application is the rearrangement of characters in a word to create other words. If all the n characters are unique, you should get n! unique permutations. You can make a list of words unique by … | |
Scientists and deficit spenders like to use Python because it can handle very large numbers. I decided to give it a test with factorials. Factorials reach astronomical levels rather quickly. In case you can't quite remember, the factorial of 12 is !12 = 1*2*3*4*5*6*7*8*9*10*11*12 = 479001600, that is 479 million … | |
Hi, I'm doing some more work on my sensor program - and it now has a GUI and graph which I'm happy with. I'm having a look at a WX python tree - which looks like a good control for what I'm looking for. The question I have is this … | |
Hello. I'm a complete Python beginner and I'd like to know how to add a fail-safe to your code so that the script is stopped after a certain phrase or key combination has been given as input. To explain further, I'm playing around with a Raspberry Pi at work. I … | |
I have a minelist[0,15] for a board 4 height and 4 width every elemnt in the board is a zero so it looks like [['0','0','0', '0'],['0','0','0', '0'],['0','0','0', '0'],['0','0','0','0']]now if I mines X in 0,15 it would look like [['x','0','0', '0'],['0','0','0', '0'],['0','0','0', '0'],['0','0','0','x']] now whereever the mines are touching it is … | |
Hi, After having come to grips with PHP, I've decided that it's time to move onto a more sophisticated language for building web applications. I've chosen Python, utilising the Django framework. Could somebody provide me with the software I will need for writing the code? My first guess would have … | |
Hi there! Ive been looking to get some help on a small script im writing to recover an encrypted word for homework. Its a 5 character word of random capital letters encrypted with the RSA algorithm. I undesrtand that Rsa is not a block cipher. Its been encrypted in two … | |
| Edit: I've discovered that the problem isn't the code, but the proxy hangs for several minutes. Is there any way I can set a timeout for this socket so that it can just request a new socket after say 10 seconds? Also, the Timer class isn't working. The classes aren't … |
Hello, I have made a programme for finding cominations of a number from the user, it is designed to take any length and then tell the user how many combinations there are. However im not sure how to find how many combernations there are. I have googled it and there … | |
Hi all - Working on teaching myself some python and have some code I am working on, I am at a point where I would like to update a parent class variable from within a subclass, I am wondering what is the proper method for doing this. Something similiar to … | |
I previously used 32bit Python 2.7 on Windows Vista. My new PC is Windows8 and 64 bit. I would like Python to work with Microsoft Office Excel. Is the best / simplest way forward to stick with 32 bit Python and 32 bit Excel? Can you mix 32 bit Python … | |
Hi, I am supposed to make a GUI using Tkinter which has basic menubar options, a optionmenu and some textboxes. Here is the code. from Tkinter import * ################ import basic libraries ################# import Tkinter import Pmw import tkMessageBox import tkFont from PIL import ImageTk,Image from mmap import mmap,ACCESS_READ def … | |
This snippet allows you to find the number of ordered permutations of items taken from a population of known size. It uses the well know algorithm with factorials. For very large populations you may want to use an approximation of factorials. | |
If you want to know the number of combinations of x things taken n at a time, you can use the Python module gmpy. The module gmpy is a C-coded Python extension module that supports fast multiple-precision arithmetic, very handy if x things reach a large number. | |
I wrote out a test for a Complex class on python but I'm getting an error. Here's what I have: class Complex: def __init__(self, real=0, imaginary=0): self._r=real self._i=imaginary def __add__ (self, other): return Complex((self._r + other._r), (self._i + other._i)) def __sub__ (self, other): return Complex((self._r - other._r), (self._i - other._i)) … | |
what does it mean by defining a variable with double underscore only at the prefix part ? like in this [example](http://pastebin.com/8e5t2eAZ) at pastebin i.e. self.__weakReference | |
I was reading this article [Click Here](http://maxburstein.com/blog/python-shortcuts-for-the-python-beginner/) http://maxburstein.com/blog/python-shortcuts-for-the-python-beginner/ In there was this example from itertools import combinations teams = ["Packers", "49ers", "Ravens", "Patriots"] for game in combinations(teams, 2): print game >>> ('Packers', '49ers') >>> ('Packers', 'Ravens') >>> ('Packers', 'Patriots') >>> ('49ers', 'Ravens') >>> ('49ers', 'Patriots') >>> ('Ravens', 'Patriots') So I … | |
I dont know what the responce will be but I kind of like the idea. Pls reply with critisim but pls stay polite. I have been Thinking if there can not be started something like a python guild. Run by an advanced python programer and the people part of it … | |
Hey all, I am working on learning python, I have a question about lists. When I call Variable x to equal numbers from a text file, I am getting the file returned in multiple lists. with open('numbers.txt') as f: for item in f: n = item.split() print (n) I end … | |
Sorry for my bad english, i have translated this task for fast, but i really neeed help. > Your task - to make automatic sfetofora (3d model). > > Traffic light works in three directions: to the two directions of movement of vehicles (in the center and from the center) … | |
This Python snippet shows how to control a VPython visual 3D sphere with Tkinter GUI toolkit button clicks. | |
How to save two images into two separate files using same python script. The two output images are correlation matrix and a graph. I was using matplotlib imshow(matrix, interpolation='bilinear') colorbar() savefig('/home/sudipta/Downloads/phppython/'+ filename +'.png') x = range(-width, width) plt.plot(x, avg_vec) plt.savefig('/home/sudipta/'+ filename +'plot' +'.png') The figures overlap each other when I … | |
how could i make the function to do the colours red, yellow and green for 5 sec delays and make the loop keep on going? [code] def trafficLights(): win = GraphWin() red = Circle(Point(100, 50), 20) red.setFill("black") red.draw(win) amber = Circle(Point(100, 100), 20) amber.setFill("black") amber.draw(win) green = Circle(Point(100, 150), 20) … | |
def is_anagram(t,u): if sorted(t)== sorted (u): return True else: return False print is_anagram('realtor', 'rotlear') # True print is_anagram('superpuff','local') # False print is_anagram('alla', 'lala') # True print is_anagram('tools', 'stool') # True print is_anagram('double', 'trouble') # False | |
def is_sorted(t): if t == sorted(t): return True else: return False print is_sorted([1,2,2]) # True print is_sorted(['b','a']) # False print is_sorted([3, 1, 5, 2, 4]) # False print is_sorted(['d', 'a', 'c', 'b']) # False print is_sorted(['a', 'b', 'b', 'd', 'e', 'e', 'f', 'g']) # True | |
What are advantieges of Ruby over Python and vise versa? Then in your opinion wich one is better for all around programming on linux and windows? | |
Let's imagine you are taking a lot of pictures and modify them with one of those fancy image editors. You burned the image files to a CD, and decided to purge some of the outdated files because your hard drive is getting full. This Python code allows you to set … | |
I am trying to work out how to remove files from a directory the files will always have a given extention e.g .txt I want to remove the filesfrom a specific directory that are older than say 14 days. Noob to Python sorry if this has been answered elsewhere, all … | |
I am writing an application that requires to ssh and telnet to a device at the same time. The pseudo code goes something like this. p1 = pexpect.spawn("ssh to the device") p1.send("run some command") p1.expect("..") p2 = pexpect.spawn("telnet to same device") p2.send("run a command that can be run only through … |
The End.