15,175 Topics
| |
i'm writing a program that reads the lines of a file. each line has a name and and number separated by one space. i want to split the string but i only want the number because i'm using it in calculations. i've skimmed through the python docs and i'm still … | |
[CODE][/CODE] def Given(rn): Given_lengths = [0] * 1000000 def rn2(n): if not Given_lengths[n]: Given_lengths[n] = rn(n) return memoized_lengths[n] return rn2 def cycle_length(n): if n == 1: return 1 if n % 2: return cycle_length(n * 3 + 1) + 1 return cycle_length(n / 2) + 1 def problem(i,j): for x … | |
Hi all, I tried running the following code. [code] #! /usr/local/bin/python import threading import time print "Press any key to start timer!" input() threadBreak = False def TimeProcess(): while not threadBreak: print "How are you?" print (time.time() - startTime) startTime = time.time() threading.Thread(target = TimeProcess).start() input() threadBreak = True input … | |
im looking for a python mud game example which i could see the coding and make my own mud, the thing is that im very new to mud if i was able to see an example of a game working then i would be able to understand what coding classes … | |
For my CS1 class we have to write a simple battleship game. I'm having trouble even knowing where to begin. After I get a basic skeleton of functions and classes I think I will know where to begin. We have to use the Zelle graphics.py module ANY help would be … | |
Well I have reflected on why my first proposal for a open source project failed. We had no base to build on, and there was to much administrivia that made us loose interest in the project. Since then I have come up with a new project idea. I started simple … | |
I personally prefer the 3 syntax over 2, but I notice most of the code snippets in this forum are for Python 2. Is it because we are still in a steady transition from 2 to 3, or is it something else? | |
Hey, can somebody help me. I have to do a programm from school. I a complete newbie in python. Can somebody tell me why my programm doesn't work and what i can do. thanks here it is: [CODE]import matplotlib import numpy import pylab lam = pylab.linspace(0.1,100,1000)*10**-6 pylab.xlabel('Wellenlaenge (mM)') pylab.ylabel('Temperatur (T)') … | |
I'm getting started with Django on Windows. And the tutorial [URL="http://docs.djangoproject.com/en/dev/intro/tutorial01/"]http://docs.djangoproject.com/en/dev/intro/tutorial01/[/URL] has me running "python manage.py <command>" from a command promt all the time. But I'm wondering: Couldn't I run the manage.py commands from PythonWin or IDLE? | |
[code=syntax] #calculate the amout of tax due to the tax given income def calTax( income ): tax = 0 if income <25000: tax = income * 0.25 elif income > 25000 and income < 50000: tax = 25000 * 0.25 + (income - 25000) * 0.33 elif income > 50000: … | |
The methods is so complicated. I want to check the execution time of each statement so that I can modify that part in order to increase speed. Thanks in advance, Raymond | |
Maybe you know the mmotps GunZ([URL="http://trinityent.org"]http://trinityent.org/home[/URL]). i have already written a few macros for it (so a program, which clicks and presses the keys for you ingame) with the program actool([URL="http://www.actool.net/"]http://www.actool.net/[/URL]). But i am tired of using this pascal-like programming language... [B]So is there a possibility to get a macro, … | |
''' Calculate the BMI of a person given their height and weight ''' def calcBMI( h, w ): BMI = w / h**2 return BMI def main(): height = float(raw_input("Enter height in metres: ")) weight = float(raw_input("Enter weight in kilos: ")) BMI = calcBMI(height, weight) print "BMI = %0.1f" % … | |
Hi, could you tell me where I can find some information about regex engine optimizations used by Python regex engine? | |
i have to write a code that tells the user to enter the amount of minutes they were allowed to use, it has to be between 200 and 800 if it exceeds or goes below then it should print "please enter minutes between 200 and 800" the problem is: if … | |
Hello My english is not good, so pleas - understat me ;-) I have two question about python ;) 1. I'm from poland, in poland letter a == Ä…, z == ź itp. Can i remove polsich letter? example in input - jacek bÄ…k in output - jacek bak I … | |
[CODE] while True: try: wd = int(input('How wide would you like your letter to be? (5 - 20)' + ': ')) break except ValueError: print ("Oops! That was no valid number. Try again...")[/CODE] If the user inserts a number that is not 5 - 20, I want the program to … | |
How would you define a recursive function that asks the user for a string and prints it from the outside in. For example, 123456 would print as 162534. Any help would be appreciated. | |
please please please help me this is my last program i have to write and i am having difficulty, this could mean a pass or fail. Thank you for your patience and help. I need a very simple code that asks the user, #input the minutes that are allowed how … | |
[CODE=python]>>> import wx >>> wx.NullBitmap.SubBitmap Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> wx.NullBitmap.SubBitmap File "C:\Python25\lib\site-packages\wx-2.8-msw-unicode\wx\_gdi.py", line 659, in GetSubBitmap return _gdi_.Bitmap_GetSubBitmap(*args, **kwargs) TypeError: Bitmap_GetSubBitmap() takes exactly 2 arguments (1 given)[/CODE] I didn't call it, I just tried to reference it. happens with all these methods wx.DefaultDateTime.Day … | |
Ive started with this program def calcFinal(): while True: try: asg1Mark = int(raw_input("Enter Asg1 mark: ")) asg2Mark = int(raw_input("Enter Asg2 mark: ")) examMark = int(raw_input("Enter Exam mark: ")) final = asg1Mark + asg2Mark + examMark return final except ValueError: print 'Please enter only numbers' def mark_check(finalMark): print "Final mark is … | |
Several weeks ago, I wrote a simple web crawler that was designed to simply retrieve robots.txt from a range of IP addresses. It was entirely CLI based, and I had it working perfectly. As my python experience has increased, I decided to start learning about GUI based programming, and decided … | |
First off this is for a homework assignment and I am new to python. I have attempted to tweak an example of how to make a table from another post on this forum but with no luck. Here are my problems: 1) my range is small (0, 1, 0.1) This … | |
I've got a little app to resize and watermark images. At the moment it only does one at a time but I would like to get it to do a full folder of images in one go. I have done this previously in VB using loops but im new to … | |
Hi everybody. Could someone explain me the usage of python's modulo operator and/or the fmod function? why do i get these results? >>> 23%0.1 0.099999999999998729 >>> import math >>> math.fmod(23,0.1) 0.099999999999998729 >>> normally 23 mod 0.1 = 0 because 23 / 0.1 = 230 exactly is there anything wrong there … | |
the random function gives you a number between 0.0 and 1.0 . im trying to get a random number between -0.5 and 0.5. i asked someone for help and they told me to go off of this: [0, 1) + .1 this changes the range to [1, 2) and i … | |
i am really wondering why this type of error continues to occur for every bluetooth code i try.. i am trying to connect to a bluetooth module... i am wondering why i cant connect to that module where in i can connect to other devices like mobile phone and laptops... … | |
i have an error with this sample code i got from the net... the error says: TypeError: unsupported operand types for +: 'int' and 'str' here is the code: from time import ctime [COLOR="Red"]import[/COLOR] codecs [COLOR="red"]import[/COLOR] inbox, appuifw box = inbox.Inbox() msg = box.sms_messages() f = [COLOR="red"]codecs.[/COLOR][COLOR="Green"]open[/COLOR]('E:/Others/listSMS.txt', 'w', 'utf8') # … | |
Hello.. Im doing some simple text processing using Python which include indexing, splitting and tokenizing text from folder. i want to improve the stemming and tagging process using MontyLingua by importing the Monty library for tokenizing and tagging. I dont know how to edit and call them in my coding. … | |
the program below simulates a game of craps and its pretty much done except for a way to get the while loop to stop. i was trying to get an input from the user when they wanted to stop rolling and to enter "n" for no but im not sure … |
The End.