14,946 Topics

Member Avatar for
Member Avatar for dustbunny000

[ICODE]import random import itertools def test(number): return random.random()*number [/ICODE] Say I have a function and I want to repeat it x times so that I may calculate the standard deviation. How can I do this? I've tried using itertools.repeat(test(5),3) but it prints repeat(value,3) which I can't calculate the standard deviation. …

Member Avatar for TrustyTony
0
87
Member Avatar for Limiter

Hi guys, I am relatively new to Python. I am trying to code a program in Python and part of it involves checking that each input only have the characters 1 to 9 occuring only once. My code are as follow: [CODE] for i in range(1,3): num = str(raw_input("Enter row …

Member Avatar for TrustyTony
0
273
Member Avatar for Razgriz411

I'm pretty new to coding with python but i'm a fast learner. I'm looking to have the python file search for something such as the number 387.120 and delete the entire line. I've tried to get it to find the line number of that line but all my attempts have …

Member Avatar for TrustyTony
0
82
Member Avatar for nawaf_ali

It was really great piece of code, I really liked it, does any body knows how to get more statistics? like word length, sentence length, paragraph length, and if possible how to plug the results into a prgram like excel or matlab to get graphs of our results? your help …

Member Avatar for nawaf_ali
0
216
Member Avatar for JasonQiao

def transpose(matrix): #FOLLOWING is my code, it is incorrect however. COULD ANY GIVE ME A HAND? O(∩_∩)OThanks :) l=len(matrix) i=0 j=0 Aj=[] T=[] for i in range(l): Ai=matrix[i] li=len(Ai) i+=1 for j in range(li): Aij=Ai[j] j+=1 for i in range(l): Aj.append(Aij) i+=1 for j in range(li): T.append(Aj) j+=1 return T

Member Avatar for JasonQiao
0
211
Member Avatar for n3red

Hi iam trying to write a script, for a calculus competition (shrot) : I wil have two competitors, both will play the game / competition until one leads by 2 points then the game is over. Anyways it goes like this: In first round first competitor enters two factors / …

Member Avatar for KrazyKitsune
0
171
Member Avatar for lucksoar

Hello all! I am a beginner programmer, and I have been told that a great first project would be to make an ASCII game, I have done all of the coding (I think) and I'm still having some problems (i.e. it won't work, at all), I believe it's the render. …

Member Avatar for TrustyTony
0
181
Member Avatar for blast

First of all, hello everybody :) I'm startint to learn Python and i have question about keyboard input. e.g. I want to enter grades (e.g. 10, 4, 4, 2) and calculate average. So i guess it should be: [CODE]grades = raw_input("Enter grades:") print "Grades:", grades[/CODE] And finaly - question.. How …

Member Avatar for woooee
0
628
Member Avatar for pythonlearning

There is a list of dataset and I need to reshuffle them randomly then partition the dataset into n groups. I am using dictionary to store the list of dataset, but I am not sure how to partition items of a dictionary into n groups? What I can think of …

Member Avatar for pythonlearning
0
157
Member Avatar for sravyen

Hello, I want to copy a jpeg file from linux to my windows machine using scp command.The program will be asking for a password later in the run after it executes the scp command. Is there a way that I can send the password to the program without a keyborad …

Member Avatar for TrustyTony
0
7K
Member Avatar for kumar86

app.Notepad.MenuSelect("File->Save As")/*saveas dialog box opened and waiting for the filename*/ regards Kumar

Member Avatar for kumar86
0
75
Member Avatar for DragSkull

Im a college student this is my first computer science class and im having trouble with my code. it will not display the print statment. This is my code thus far. import random choice = raw_input("what die would you like to use: ") d4 = random.randrange(4)+1 d6 = random.randrange(6)+1 d10 …

Member Avatar for ScottieF
0
146
Member Avatar for pixelss

hello, i have to create a program that open a file, read the file, add the number form the files, and display the total sum. Here is what i have [CODE] numbersFile = open('numbers.dat', 'r') line = numbersFile.read() for line in open("numbers.dat"): nums = [int(x) for x in line.split()] #close …

Member Avatar for TrustyTony
0
104
Member Avatar for pacers10

I am stuck on a problem with no idea how to start. I need to create a program that creates a file witha index that tells you which line of the file each word appears on. i Have this so far but i may be way off.[CODE]Import t = open(""),"r") …

Member Avatar for TrustyTony
0
126
Member Avatar for convoluted

Hello all. I'm having a bit of trouble trying to figure out how to access data I input into a ctypes array object. This is used with a hardware SDK, so I can't really change the data format at all. Here's the code: [CODE] from ctypes import * MsgDataType = …

Member Avatar for convoluted
0
2K
Member Avatar for wheatontrue

Dear all, When I use the pymedia module to play a WAV that I've converted from an mp3 file, it plays it for me twice. I don't know why - my media player (i'm on linux, so mplayer) plays the WAV file only once. Here's what I'm doing: [code]f= wave.open( …

0
49
Member Avatar for sss33

Say that you have a file and the list of numbers like 10 20 16 17 82 93 87 How could I add/subtract/ or multiply these individually?

Member Avatar for pixelss
0
71
Member Avatar for ljjfb

Hello, all professionals, I have a question about using python to pass argv to another script. And here's the problem: I have installed a Virtual Machine(Windows XP) in my Host system. Right now, I propose to create a script located in my Host system to pass a argument to the …

Member Avatar for ljjfb
0
137
Member Avatar for Archenemie

I basically want to map out folders and subfolders in a dictionary and i have this code ive written, but instead of adding each filename to the dictionary it overwrites it each time. Any suggestions? [CODE]for fname in os.listdir(os.getcwd()): print fname x += 1 maincat = {fname} print "x = …

Member Avatar for Archenemie
0
105
Member Avatar for iwanttolearnc

im quite new to python so forgive my stupidity. ive downloaded numpy and here are a few things i understand regarding images and numpy 1.images are made up of pixels that have coordinates, a 2d array i believe 2.numpy has the ability to handle arrays and split them what i …

Member Avatar for iwanttolearnc
0
202
Member Avatar for testie

Hey guys, is there any alternative methods to string slicing? An example output would be: input: dani output: d da dan dani I did this with string slicing, but am wondering if it is possible to do the same thing without slicing. Anyone help out? Testie,

Member Avatar for TrustyTony
0
550
Member Avatar for sahil1991

hi friends, i have done programming in c++ and now thinking to start some new language........ i considered java initially but now i am also thinking about python but,the problem is i dont kno anything about python(especially features,powers).. so plz guide me about it and also i wud like to …

Member Avatar for sahil1991
0
106
Member Avatar for MTN

I'm trying to write a code where I should have a few questions and an input for an answer. If the answer is correct, then it will tell me correct and wrong if it is wrong. I found a similar solution on this site, but the difference is that I …

Member Avatar for cghtkh
0
98
Member Avatar for newbieha

def sort(l, x) if len(l) <= 1: ### if my list is smaller than 1, simply return l return l else: ### Here is the problem i don't know how to solve - how to find smallest element within a list using recursion? I've tried to call another function in …

Member Avatar for TrustyTony
0
2K
Member Avatar for ch1zra

can I somehow extract single file from a zip archive without replicating directory structure inside zip file ? for example file I need is : archive.zip/folder1/folder2/fileIneed.doc when I use zipfile.extract I get the file, but I get it in destination folder with same directory structure. I'm at home now and …

Member Avatar for Gribouillis
0
138
Member Avatar for danholding

hey guys n girls, im using python 3.1.2 i am currently creating a process to: 1) check a directory does not exist, 2) check for illegal char's from a list i have made, 3) pass it to a program,-program creates directory, 4) and passes a value back to python 5) …

Member Avatar for Gribouillis
0
261
Member Avatar for lewashby

I'M getting an error in the following program on line 38 to a function call. The function is in the gameobjects module and the there's an error there as well on line 21. Here's the code. Code:[CODE] background_image_filename = 'sushiplate.jpg' sprite_image_filename = 'fugu.png' import pygame from pygame.locals import * from …

Member Avatar for Gribouillis
0
185
Member Avatar for mikeyj9009

I really need help. The output is supposed to read a text file with the coordinates and print them to a text file, but I am not sure what lines of code to write and where to insert them. Here are the coordinates that are in there own text file: …

Member Avatar for woooee
0
101
Member Avatar for mtmalleus

Hey guys. I'm new to Python. I kinda blundered into a CIS major at the university I attend, and I have to say, I haven't enjoyed the Python class so far. It's so... esoteric. I'm having a TON of trouble grasping what the rest of my class view as simple …

Member Avatar for Schol-R-LEA
0
172
Member Avatar for lewashby

[CODE]import pygame from pygame.locals import * from sys import exit pygame.init() screen = pygame.display.set_mode((640, 480), 0, 32) font = pygame.font.SysFont('arial', 32) font_height = font.get_linesize() while True: for event in pygame.event.get(): if event.type == QUIT: exit() screen.fill((255, 255, 255)) pressed_key_text = [] pressed_keys = pygame.key.get_pressed() y = font_height for key_constant, pressed …

Member Avatar for woooee
0
6K

The End.