15,181 Topics
| |
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 … | |
so im trying to simulate a walk where the user will randomly take either a step forward or backwards, hence using the probability of a coin flip. i think the program is pretty much self explanatory. i just need help debugging it because it doesn't seem to work properly yet. … | |
Hi Guys! I am a Python noob. I wanted to merge data and eliminate duplicates. I have the solution. Now I am stuck at dumping the dict contents to MySQL. Any help is really appreciated. Data : [QUOTE]a b c d e f key dupe -------------------- 1 d c f … | |
Hi there, As a student I am new to python and am struggling with the following program I have been tasked to create. My code so far is like so. The idea is that the function will take a guess x, incorporate an arbitrary function f(x) and then take feps, … | |
Hello everyone! I have task to write a program that would read a data from any txt file and visualize it on a bar chart using turtle module. I have to structure the program using modules and functions for nice design. The program must be fit for any other txt … | |
Hello, I want know how to find some of words in a file. For example : find one word [CODE]if "word" in open(file).read(): print file[/CODE] I wand do that but with 5 words [ word1 , word2 , word3 , word4 , word5 ] If find word1 or word2 or … | |
Country Gold Silver Bronze Total US 9 15 13 37 GE 10 13 7 30 CA 14 7 5 26 NO 9 8 6 23 AU 4 6 6 16 RF 3 5 7 15 KO 6 6 2 14 CH 5 2 4 11 SW 5 2 4 11 … | |
i found this code [URL="http://www.daniweb.com/forums/thread233959.html"]here[/URL] and i tested the code and it isn't working for me this is what my code looks like: [CODE] # PURPOSE: to count the number of words, lines, and characters in a file # # INPUT(S): a file name to be used # # OUTPUT(S): … | |
Anyone know of a way to tell the difference between an inherited class method and a individually defined one? ie: [CODE=python]class test(str): def unique(self): pass x = test() # how to test for difference between x.unique # and x.lower[/CODE] | |
can any one please give me a link from where i can find out how python executes internally,i mean the way objects are declared, stuff stored etc. | |
[CODE]from Tkinter import * import random weapons = ("rock", "paper", "scissors") class Application(Frame): def __init__(self, master): Frame.__init__(self, master) self.grid() self.create_widgets() def create_widgets(self): Label(self, text = "Choose your weapon!\n" ).grid(row = 0, column = 0, sticky = W) Label(self, text = "Weapons:" ).grid(row = 1, column = 0, sticky = W) … | |
***Editted: added second problem I have this code, how do I make it stop once it's found the first instance of the [B]if[/B] happening. break, myparser.close(), and return don't work. [CODE]from html.parser import HTMLParser class MyHTMLParser(HTMLParser): def handle_starttag(self, tag, attrs): if tag == 'a' and (attrs[0][1].find('downloads&showfile') != -1): print(attrs[0][1]) print(attrs[1][1]) … | |
Hello Python forums, I started working with Python recently and picked up a book. The book stated discussing using the ctypes module in python which is slick because it's exactly what I need to be learning. I started trying to test my knowledge by implementing a simple, singly linked list … | |
I have files that contain lists of lists. Each file has about 20.000 lists that each list member is a list of itself with 15 values. Think of it as a database table. I know we can use a binary search to find a member of a list but can … | |
I want to get a list with just folders (without subfolders). Any idea how to do that ??? | |
I will donate $10 via paypal whoever can help me with this code. heres my assignment [QUOTE]Write a Python class named "Car" that has the following data attributes (please create your own variable names for these attributes): - Year_Model (for the car's model) - Make (for the car's maker) - … | |
Hey guys, first time poster, relatively long time reader -- I am struggling creating a buffer class in python for my class. (relatively new to the language). Here is the basic idea I want to do: Implement a class that buffers text. The write() method adds a string to the … | |
Hello All, I'm pretty new to python but have been programming, for a few years hobby wise and decided to try python after I found how concise the syntax was and with a computer science bent. So I'm writing a little code for a work related thing, simulating some basic … | |
Hi, I've made a small program which has 2 buttons and each does certain thing. Here's a simplified version of the code. Thing is it works fine except that the button freezes and stays in a clicked position and whole GUI freezes until the command is completed. As far as … | |
Is it possible to limit a certain variable to only certain type? For example, i have a class named AccurateStr. How can I make sure that the variable "as" is an instance of AccurateStr? Similarly, how can I make sure a variable is a positive int, str etc without the … | |
hi, I am new to python :). I am having a file say "test.c" test.c file contains test1 test2 test3 test4 and my output should be write in a file as newtest.c... -h test1 -e temp -x temp2 -o temp3 -h test2 -e temp -x temp2 -o temp3 -h test3 … | |
i am having an error with this simple bluetooth console it has error that says: NameError: name 'sys' is not defined call') here is the code sorry i am a noob in python i am trying different samples for me to learn hope somebody will enlighten me: [code=python] import socket … | |
Hello all, I normally lurk around and solve most of my issues by reading other threads. I have run into an issue and I am trying to figure out what I am missing. I am rather new at this so thanks for any advice. What I am attempting to due … | |
i have a problem... i am new to python... and i have found a program that reads an sms directly from the phone's inbox... i am using nokia 6600... i just want to ask how will i be able to copy the sms file to a string? here is the … | |
Most people would do something like this: [icode]input("Press any key to continue") #or raw_input[/icode] This way, if the user presses a key other than the Enter (return) key, then the program will still continue. It looks something like this: [URL="http://i42.tinypic.com/2yvp9hj.png"]http://i42.tinypic.com/2yvp9hj.png[/URL] |
The End.