15,190 Topics

Member Avatar for
Member Avatar for kay19

from __future__ import print_function, division #requested per VPython import time from visual import * #make sure this is asterisk char, copy/paste no go ## constants mzofp = 1e-7 L = 2.5 q = 2*1.6e-19 scalefactor = 7e-9 deltat = 9e-20 #objects & initial conditions particle = sphere(pos=vector(0,0,-4e-10), radius=1e-11, color=color.red) velocity …

Member Avatar for kay19
0
178
Member Avatar for otto531

I've been looking around for an answer to this but have had no luck. I need to take two files and print the top most frequent words they have in common as well as their combined(sum) frequencies. This might be simple but I'm pretty new to programming. Any help? def …

Member Avatar for bumsfeld
0
309
Member Avatar for Alkajak

class BTNode(object): """A node in a binary tree.""" def __init__(self, item, left=None, right=None): """(BTNode, object, BTNode, BTNode) -> NoneType Initialize this node to store item and have children left and right, as well as depth 0. """ self.item = item self.left = left self.right = right self.depth = 0 # …

Member Avatar for dashing.adamhughes
0
262
Member Avatar for johans22

I have numpy type array, array[x][y], 16bit, little endian. How to save this to a tiff file as an image?.

Member Avatar for johans22
0
160
Member Avatar for keitaurin

Let's say I have a user input a string. string = input("enter a string") and that string ends up being something like "hello world!" but with a lot more whitespace. string = "hello world!" I want to condense this user's input so that instead of all that whitespace I only …

Member Avatar for Lardmeister
0
183
Member Avatar for OmK@r

Hi Friends, I want to connect to a linux machine using a private key login as password from another linux machine. I want to connect this using a python script. Thanks in Advance, Omkar

Member Avatar for Gribouillis
0
305
Member Avatar for 3e0jUn

So I have a code that prints out the `sys.argv` when the program is ran. How can I parse $ python ./arch.py install * to show `["./arch.py","install","*"]` Instead of `["./arch.py","install",#other files in directory]`?

Member Avatar for deceptikon
0
199
Member Avatar for OmK@r

Hi Friends, I had a issue with telnet conncection in python. Can you send me a working module to connect to telnet windows from a linux machine using python scripting.. Thanks in Adwance, Omkar

Member Avatar for OmK@r
0
4K
Member Avatar for Lardmeister

Anybody out there that used Python on an Android system? Something like the subset on http://pygame.renpy.org/

Member Avatar for M.S.
0
218
Member Avatar for mksha

Hi Guys, I am kind of new to python and started working on python from February2013. I have a script which run on linux machine. It captures the available RAM from the system and then tries to eat it up. I am using subprocess.Popen('free',...) command and for first loop it …

Member Avatar for mksha
0
466
Member Avatar for clouds_n_things

So, quick question, (has to be just something I'm missing), if I want to concantate a string and integers in a url, is there a way to do so? I'm sure there is...I mean this IS python! from urllib2 import urlopen width = input("Please enter a width specification here: ") …

Member Avatar for clouds_n_things
0
181
Member Avatar for johans22

import matplotlib.pyplot as plt plt.plot(x, y, 'b-') plot.legend ( ... ) 'put legend on left, i do not have the actual code with me. plt.show() How can I resize the plot window to show the legend on the left side?. Also, I like for program Not to stop when calling …

Member Avatar for Lardmeister
0
138
Member Avatar for clouds_n_things

So I'm writing a personal bank tracker for myself, and I'm having a bit of trouble with a line of code. The ID_Pin method below is equal to 0000, however when i try to create an instance (any instance of the Account class), it returns the "Access Denied" bit that …

Member Avatar for clouds_n_things
0
176
Member Avatar for dude1

i have a problem im trying to solve in python but I'm not sure if its possible ive got lists of data one line that is the full name Eg. name:John Doe and the line below is a the user ID Eg. userID:jdoe i have both of those being made …

Member Avatar for Lucaci Andrew
0
294
Member Avatar for welshly_2010

how can i add data to a label that i have and keep updating it based on the folder selected here my code so far def listDir(): dirname = tkFileDialog.askdirectory(parent=root,initialdir="/",title='Please select the file you would like to scan') myvar.set('Current Folder Selected is: ') label = Label(root, width = 30, height …

Member Avatar for vegaseat
0
168
Member Avatar for krystosan

why does this gives error `print "module {0}".format(key)` , i hope this is nt the python version problem...

Member Avatar for vegaseat
0
343
Member Avatar for vegaseat

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 …

Member Avatar for vegaseat
1
6K
Member Avatar for vegaseat

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 …

Member Avatar for sneekula
2
5K
Member Avatar for rev_ollie

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 …

Member Avatar for rrashkin
0
218
Member Avatar for syfr

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 …

Member Avatar for Gribouillis
0
955
Member Avatar for sugarzzzz

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 …

Member Avatar for woooee
0
120
Member Avatar for ebc3142

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 …

Member Avatar for LastMitch
0
215
Member Avatar for abacus_x

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 …

Member Avatar for blj.davidson
0
163
Member Avatar for carlpike

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 …

Member Avatar for chriswelborn
0
158
Member Avatar for aVar++

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 …

Member Avatar for Ene Uran
0
286
Member Avatar for lancevo3

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 …

Member Avatar for Ene Uran
0
1K
Member Avatar for robert99x

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 …

Member Avatar for vegaseat
0
312
Member Avatar for superbhimanshu

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 …

Member Avatar for vegaseat
0
426
Member Avatar for vegaseat

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.

3
3K
Member Avatar for vegaseat

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.

3
465

The End.