15,185 Topics
| |
Here's the code I need to loop: [CODE] dmg = random.randrange(1, 10, 1) print "You have decided to attack the giant rat." ratHP = 100 ratHPN = ratHP-dmg print "you did" , dmg , "damge to the rat, giving it" , ratHPN , "left" ratHP = ratHPN [/CODE] If you … | |
Hi all, I would like to ask. Im Fairuz and the new member for this forum. I having problems to sort the multi dimentional array in python. ie: [('DcaUiVb_B09398-11', [None]), ('m3sui_R66441-35', []), ('m3sui_r26557-01', []), ('m3sui_R31225-24', []), ('m3sui_r66147-03', []), ('m3sui_R31225-23', []), ('m3sui_R30803-10', [])] I have the list but im having problems … | |
Hi.. Ive been doing python for about 2 days now (my 1st programming language) and im wondering, after ive made the .py file, and all the codes in it, how do i run it? To be honest im not even sure if the term compiling is right... I am doing … | |
This might be a little challenging, but I'd like to know. [code=syntax]from math import sqrt y = int(raw_input("> ")) x = sqrt(y) print x [/code] In this code, say I input 4 for y. The output will be 2, naturally. However, say I have 2 for y. I'd get something … | |
In the book, wxPython in Action (page 65), the following code shows how to bind an event to a frame (self) and to a button. In the case of the frame event (wx.EVT_CLOSE), no source argument is specified because the event is being bound to the object refenced as "self". … | |
The user enters a number and the program should output that amount of rows and colunmns. I have tried a couple of different ways butcant quite get it even though I think I am close. for example if 10 is entered it should look something like this: O OO OOO … | |
im currently running on windows 7 and i cant seem to find some suitable installation of mysql for python 3.1.2.. any help on this?my professor havent gave me any links on where to download it, anyone would mind helping me on this? or as i tried import mysqldb and i … | |
Hello, I have this code : import urllib import zipfile import re totaal = 0 commentaar = [] lus = True image = urllib.URLopener() image.retrieve("http://www.pythonchallenge.com/pc/def/channel.zip","channel.zip" ) bestand = "readme.txt" zf = zipfile.ZipFile('channel.zip') while lus == True : for filename in [ bestand ]: try: data = zf.read(filename) except KeyError: print … | |
I've been doing programming in tkinter for awhile now and I came across a problem...this problem only shows up after a single part but here is the code...kinda lengthy.if you go to the equip menu and equip bare neck you can't change necklaces again. any help in shortening this or … | |
so now that i have gotten farther in the code, it prints the substrings correctly, but i can't get the program to stop correctly. basically, i'm looking for the longest common substring. def main(): input1 =raw_input('Enter string: ') input2 = raw_input('Enter second string: ') if input1 > input2: str = … | |
Hi, I have just started my first semester in a Bachelor program 'Computer Engineering'. I have above basic knovledge in Java SE and currently am interested in Python. The problem is that I'm facing some difficulties in determing my purposes about my future career in IT field. I used to … | |
Hello Please excuse my lack of knowledge to python, but I just cannot understand how time complexity works. I've read many threads on this forum regarding time complexity but I am still quite confused. Our prof has given us this example: [CODE]def foo(n): ! while (n > 0): ! ! … | |
I have a pretty simple coding function that returns all possible substrings of a string including the string itself def main(): str = raw_input ("Enter first string: ") size = len(str) for sub_len in range (1, size + 1): for idx in range (0, size - sub_len + 1): sub_str … | |
am using debian lenny and tried to create a shutdwon script using python import os os.system("sudo shutdown -h now") i cant use this in debian lenny then how will i implement | |
Can someone please direct me to the code for the class <int> in python. I know that it must have written in C, but I could not understand, where to ask this query. Though I tried to figure it out myself, but could not even understand, which folder to attack … | |
Hello everyone. This is my first post so if something doesn't work, bear with me. I'm a beginner at python and tried to write a program that will calculate Average Word Length. I wrote what I thought should work but the final answer keeps coming out to an average of … | |
Hello, I have a image with a grey band in it. How can I know the values of only the grey band of the image ? Roelof | |
So I have this list of strings. They all of the strings have a 18 capital letters. I want to assign each letter a value and them sum up the total score. [CODE]window=['SALHWRAAGAATVLLVIVL', 'ALHWRAAGAATVLLVIVLL', 'LHWRAAGAATVLLVIVLLA', 'HWRAAGAATVLLVIVLLAG', 'WRAAGAATVLLVIVLLAGS', 'RAAGAATVLLVIVLLAGSY', 'AAGAATVLLVIVLLAGSYL', 'AGAATVLLVIVLLAGSYLA', 'GAATVLLVIVLLAGSYLAV', 'AATVLLVIVLLAGSYLAVL', 'ATVLLVIVLLAGSYLAVLA', 'TVLLVIVLLAGSYLAVLAE', 'VLLVIVLLAGSYLAVLAER', 'LLVIVLLAGSYLAVLAERG', 'LVIVLLAGSYLAVLAERGA', 'VIVLLAGSYLAVLAERGAP', 'IVLLAGSYLAVLAERGAPG', 'VLLAGSYLAVLAERGAPGA', … | |
Hey, I am working on a program for my class where we are supposed to count the letters that occur in a given string, with decreasing frequency. For instance, it would say there are 150 A's, 234 B's, 25 C's, etc. Plus, it would then become possible to sort the … | |
I am trying to insert data from a text file into an SQL table. I'm getting this error: " csv_data = csv.reader(file('TxtFile1.txt', 'r')) TypeError: 'list' object is not callable " [code] import MySQLdb, csv, sys conn = MySQLdb.connect (host = "localhost",user = "a", passwd = "b",db = "c") c = … | |
Hello, Now I'm making a program for creating language glossaries, but the problem is that windows uses ANSI for encoding text files, and the program that will read these files (which is not mine) only displays words in utf-8 encoding. Since my program is multiplatform, it can also work under … | |
I have the code below and I get everything except the bonus in the output. I tried it a few different ways and the bonus never comes out right after the staff and sales. #get user input for sales bonuses and make calculations #print headers print" Sales Tracking Program" print … | |
What is parsing and how do I use it? My guess is that parsing is something that locates a keyword in a statement. My guess, okay? I don't understand wiki. If it isn't, is there something that can locate something in a statement and do something if it finds it? … | |
I need the output of the following code to be printed in a text file. So far it creates the text file, but it does not print anything in it. Any help would be appreciated. [CODE]def findSlope (x1, y1, x2, y2): rise = y2 - y1 run = x2 - … | |
If we have more than one if statement, is it possible to combine them? Like this: [code=syntax]x = raw_input("> ") if x == a: print "1a" elif x == b: y = raw_input("> ") if y == a: print "1y" elif y == b: print "1b" elif y == c: … | |
hi...i am trying to install python 2.6 on my debian system.. I followed the following instructions[B] [url]http://www.fps-gamer.net/installing-python-2-6-on-debian-lenny/[/url] [/B] on doing [B]aptitude install -t testing python-central[/B] i get [B]E: Invalid record in the preferences file, no Package header[/B] can any body pls reason out:( | |
This is used for finding the roots of a parabola. The parabola must have a number in front of x2 (x squared), a number in front of the single x, and a following number, or you can have a perfect square parabola. (in the form "number x2 - number") This … | |
I am new to this forum (and python), but since I found excellent post here, I figured it would be the best place to post this question which is two part: I have many (+100) .txt files which are space delimited (not csv or tab, possibly referred to as ASCI?) … | |
The with statement allows all sorts of syntactic sugar in python. This snippet defines two contexts: [icode]inevitably[/icode] and [icode]preferably[/icode] which register a function call to be executed at the end of a block of statement. Although they are not very useful (the function call could be written directly at the … | |
Hi. I was wondering if anyone knows how to establish x,y,z coordinates in python. I want to be able to extract this data from a text file. Here are sample lines in my text file: [CODE] ATOM 1 N GLN A 4 62.131 49.287 59.621 1.00 67.10 N ATOM 2 … |
The End.