15,406 Topics
![]() | |
Ahoy Sailors! So there's two bits to my Python built software, The Parent and the child. The Parent comes in PE executable format so as you can simply right click and view the source. Now we're needing to do the same with the Child applications the Parent is going to … | |
Hi, I am a beginner-novice programmer using Python to build custom tools in ESRI's ArcGIS. I have what seems like a simple problem, but I am afraid I'm missing a core concept. Here goes... In this simple example I assign string values to some variables and then change the text … | |
Heya Daniweb, I've been working on Regular Expressions, thanks to cghtkh who told me about them. I've used resources from: [URL="Newthinktank.com"]NewThinkTank.com[/URL] [URL="http://docs.python.org/library/re.html"]Python Regular Expression Documentation[/URL] and [URL="daniweb.com"]Daniweb.com[/URL]! I figured I'd share my code, ask a few questions, and get some feedback on what I did if I can. Feedback helps … | |
I have to write a table called tempconv.txt, the table should have temps from -300-212 fah and the cel equivalents with steps of 10 or 20, presented in 2 columns.I keep getting a syntax error. I think i am having trouble with the opening and closing of the file. Thanks … | |
[CODE]import random name = raw_input("Write your name:") print "Hello",name,"you're about to play Hangman." print "Everything you get a wrong guess, you will get a {}, if the word were Nicky you'd get 5 tries." raw_input("Press [[ENTER]]") words = ["bat","girl","epic","blocks","block","chips","boy","fire","fox","school","community"] wordnum = random.randrange(1,11,1) hangword = words[wordnum] a = len(hangword) print "The … | |
This is program for figuring out cost of carpet at X length Y Width and Z cost/sqft (turned to yard). I am not very strong in looping yet, but I am pretty sure that is what has to be done here. Ideally at the end I want to ask the … | |
Hi all.. I am new to Python and badly need help...I am trying to run a DOS batch file from Python..I have given the inputs also..It runs half and then exits at the point of time when I need to give answer to whether I need to replace two files … | |
hi... how can this be done using python 1.prompting user for a file location from within a script 2.reading the file location entered by the user 3.storing it in a file like object | |
ive been trying my hand on using modules to make my codes cleaner. i started off with a simple case. i created a module, usermodule.py, which i will pass to a main program openme.jpg - 640x480 [CODE] #this is usermodule.py import Image #image = Image.open ('openme.jpg') #imload = image.load() def … | |
hi... am using pysnmp module to do an snmp get on a USB key status from pysnmp.entity.rfc3413.oneliner import cmdgen #--query on ccmSDIDUKeyStatus errorIndication, errorStatus, errorIndex, varBinds = cmdgen.CommandGenerator().getCmd( cmdgen.CommunityData('xxx', 'xxx', 1), cmdgen.UdpTransportTarget(('192.168.5.157', 161)), (1,3,6,1,4,1,18489,1,2,4,2,8,0)) varBinds gives the following: [(ObjectName('1.3.6.1.4.1.18489.1.2.4.2.8.0'), Integer('2'))] I need to print the key status, based on varBinds, … | |
I really need help with this...i'm trying to make a game that where user guesses a word and it tells the user 1: the right number of letter in the right place 2: the number of letter that is right in the wrong place but when i test it out, … | |
When handling command-line arguments, I roughly know getopt will work, but have never used it before. The documents on some books seems not very informative, if read multiple arguments from the command line, is it right to use sys.argv[1], sys.argv[2], etc to assign the arguments to respective variable in the … | |
I have a set of text files in a folder. I want to read each file, convert the contents of the file to lowercase, remove punctuations and save them all in another directory with the same filenames. How can i do that??? | |
Ok, I'm really really new to Python. I've installed Python 2.7 and is using IDLE (GUI). I just wrote 2 classes, Car and CarsDB, but I can't load them together to use them. [CODE] class Car(object): 'A car with its own information like make, year, model, price.' def __init__(self, mk, … | |
ok the guy helpes me with my problem in my last post but I need to switch this: #This module determines highest value in list def highestMonthNumber (rainfall): month = ['January','Febuary','March','April','May','June','July','August'\ ,'September','October','November','December'] highestMonthly = 0 for m, n in enumerate(rainfall): if n > highestMonthly: highestMonthly = n highestMonth = m … | |
Hello all, My son is taking a computer programming class and we have been working on the exercise for over 20 hours. He posted a thread about needing more help with lists. If anyone can please help us with enumerating to the lowest rainfall month I would be forever grateful.I … | |
hi how you can help me i've been trying to connect a line from a point i click to a square that have been placed there previously but have no idea how to do it, could you help please?? | |
[CODE]im=Image.open ("trial.jpg") a = im.resize((300,300), Image.ANTIALIAS) b = a.save("im.jpg") im1 = Image.open ("im.jpg") loadres = numpy.array(im1)[/CODE] ive resized image trial to 300x300 image and saved it as im.jpg. but once i turn it into an array and check image sizes this is what i get [CODE]>>> im.size (450, 400) >>> … | |
Hi, I built a popularity cloud but it doesn't work properly. The txt file is; 1 Top Gear 3 Scrubs 3 The Office (US) 5 Heroes 5 How I Met Your Mother 5 Legend of the Seeker 5 Scrubs ..... in my popularity cloud, names are written their frequency times. … | |
I have been messing with this program for my class for days now. I can get the program to run fine....I can get it to return highest value in list but i need it to return the month it occurs in. Here is the exercise as it appears in my … | |
In the following program I'M getting an error with the blit function. The error is invalid destination position. background_image_filename = 'sushiplate.jpg' sprite_image_filename = 'fugu.png' [CODE] import pygame from pygame.locals import * from sys import exit from gameobjects import Vectory2 pygame.init() screen = pygame.display.set_mode((640, 480), 0, 32) background = pygame.image.load(sprite_image_filename).convert_alpha() sprite … | |
Hey, it's me again. I have a Ceaser Cypher here: [CODE]letters=list("abcdefghijklmnopqrstuvwxyz") def Encrypt(): for i in range(int((len(word)-1))): curletter="".join(letters).find(word[i]) if (curletter+key)>(25): if (curletter+key)<0: i=(curletter+key) i=[(curletter+key)-(curletter+key)] else: i=(curletter+key)-(25) print (curletter+key) word[i]=letters[curletter+key] return def Decrypt(): return word=list(input("Type in some letters:")) key=int(input("Type in a key:")) choice=int(input("1) Encrypt\n2) Decrypt\n:")) if choice==1: Encrypt() else: Decrypt() print("".join(word))[/CODE] … | |
I want to shorten the lower half of this code into a loop statement. The only(x) function is an imported function that makes sure 1 to 9 occurs only once. [CODE] num_1 = str(raw_input("Enter set 1: ") num_2 = str(raw_input("Enter set 2: ") if not only(num_1): ##These two "if not … | |
Hey, I have a homework problem in which I have to multiply two polynomials. I am assuming that the 2 polynomials can each be of any length so I am stuck as to how I am supposed to do that. My homework sheet derives how to do it like this … | |
[CODE]list=[] list_start=[[1,2], [2,2], [1,3]] for element in list_start: list.append(element) list[0].append([2,3]) print "list=", list[/CODE] The result is, list= [[1, 2, [2, 3]], [2, 2], [1, 3]] instead of list= [[1, 2], [2, 3]], [2, 2], [1, 3]] If check: >>> list[0] [1, 2, [2, 3]] >>> list[0][0] 1 >>> list[0][2] [2, … | |
3. How many 3 digit numbers are divisible by 17? Write a function to print them and return the sum. (The sum being the sum of the 3 digit numbers that are divisible by 17). 4. Write a program that does the following to an image: changes black pixels to … | |
[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. … | |
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 … | |
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 … | |
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 … | |
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 | |
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 / … | |
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. … | |
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 … | |
I want to build a large scale web application but I'm torn between the three. The main points I'm looking for are productivity, speed, hosting, community, scalability, learning resources and technology (AJAX, database, threading, MVC etc). Here are my impressions of them: [B]PHP:[/B] de facto for web development, big community, … | |
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 … | |
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 … | |
app.Notepad.MenuSelect("File->Save As")/*saveas dialog box opened and waiting for the filename*/ regards Kumar | |
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 … | |
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 … | |
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") … | |
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 = … | |
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( … | |
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? | |
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 … | |
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 = … | |
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 … | |
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, | |
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 … | |
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 … |
The End.