15,185 Topics
| |
Hi guys! I'm a beginner in Python and I am having a bit of trouble with this program. What I need to do is ask the user how much they must pay, and how much they are paying. Example: Buying groceries that cost $10.27 and the user is paying $11.00. … | |
Hi, I as a Python novice I throw myself at the mercy of experts in this forum. Could someone post a simple example of how to implement urllib2's proxy authentication. I've read all the references google returns as well as searched this site and cannot find an example that I … | |
can anyone show a small sample of how [B]optparse module[/B] can be used to parse a command line arguement? the command line is somewhat like: <scriptname> -ip<ip address> -opt1/opt2 | |
The class GoogleSuggest will help you to grab the Google suggestion(s) for given expression. [B]Note[/B]: The urllib2 module has been split across several modules in Python 3.0 named urllib.request and urllib.error. The 2to3 tool will automatically adapt imports when converting your sources to 3.0. Example and output: [QUOTE] >>> ================================ … | |
Hey all, I have a text file and I want to find out the top 40 most used words in the text file. I managed to do that. But, I have another text file that has hundreds of "stop words." When looping through the text file to find out the … | |
Guys I am trying to check the size of a item inside a list. How do I search through a list and return items of a certain size? This is what got: [CODE]#This is meant to search through a .txt file an return the words with 20 characters fin = … | |
[CODE] def main(): #Check to see if quickdraw is located in the correct palce quickfile = file_existance() quickdraw = subprocess.Popen(['java', '-jar', quickfile], stdin = subprocess.PIPE) #Intro, explaining what will occur throughout program intro() # x_coordinate(1) y_coordinate(1) initial_ball(quickdraw) def file_existance(): filename = raw_input("Please enter the name of the file: ") while … | |
I wrote the following function in Python3 for finding the largest product of numbers along the diagonal(top-left to right-bottom). [CODE=python] def GreatestOnDiagonal(data): '''Returns greatest product possible by multiplying 4 numbers in the diagonal ''' grtProduct=1 for item in data: for n in item: product=1 for r in range(0,4): try: d=data.index(item)+r … | |
Hi. I'm very new to python and I'm trying to write something that is conceptually very simple but I'm not sure how to approach it in python. I have 2 files, and basically want to open one file, and replace the content with something in another file. Example: file1.txt only … | |
Guys, I am trying to sort a list. But Python does not let me set my new sorted list into a variable. here: [CODE]list1 = ['a', 'z', 'b', 'y'] sorted_list = list1.sort() return sorted_list[/CODE] When I run this on my interpreter, instead of printing my string sorted, it prints "None" … | |
I'm new to Python, so bear with me..... I'm calling the Dislin plotting package from python to plot in a wxPython panel. This works OK but the plot gets grayed out when another window is moved over it. There is a Dislin function, sendbf, which updates the graphics window with … | |
Hi, I am new in python and programming basically. I have a code that compare 2 files by the first column and prints a file with the common lines. But i need it to compare the first 3 columns and print the file. I kind of have and idea of … | |
Since Django is not yet compatible with Python 3, what are other good web application development frameworks compatible with Python3? | |
Hi all, Ive been working on this little piece of code down there that removes the odd numbers from a list of numbers. I get an "IndexError: list index out of range" whenever I try to run it. From what I understand, it means that l[i] is attempting to use … | |
Hi, I am trying to split a string and return specific words. I know that using string.split() turns the string into a list of specific words. But how would I go about returning specific words? like the ones that contain certain letters? This is my code so far: [CODE]def e_words(m): … | |
Well that someone would be me. I finished three quarters of C, one quarter of Java, and one quarter of Python at my community college. I think it's about time that I start contributing something to a project, but I have no idea what I want to do. I tried … | |
Hello, I'm new to python world (I had only programmed on Visual Basic or Delphi), right now I'm doing a program on ironpython studio in wich I need to switch between forms. The thing is that I don't know where and how to initialize "form2" from "form1" to call it. … | |
The first time my code loops through my nested while loop it works. But the second time it doesn't- I don't know why. Could someone tell me the reason. [CODE]m = [['__', '__', '__'],['__', '__', '__'],['__', '__', '__']] z=1 count=9 f=[0,2] from random import choice w=choice(f) from random import choice … | |
I need to define a function that translates an sentence from present to past. A. put all words in lower case and omit all punctuation B. Plural and singular verbs should be recognized C. verbs ending in "y" change to "ied" D. verbs ending in "e" add "d" E. other … | |
Is there a way in python to look through a file line by line and find a word in that line, but only if the word is the first word in the line? Like if it was looking for the word "apple" then it would only notice if the line … | |
Hi, how do I write a list to a file on mac os x? I have tried everything..... file = open('test.txt', 'w') mylist = ["rocks","box"] file.write("This doesnt work either") file.write(str(mylist)) | |
Hello everyone, i faced some problem i cannot solve myself so any help would be appreciated. so here is the task. i have an integer, for example 123. then i want to simulate backspace pressed 3 times and then i want to simulate keyboard presses 1 2 and 3 and … | |
I need to write a Python Turtle graphics program to output an n-pointed regular star, where n is an odd integer from 5 -to- 99 input by the user in answer to a question prompt. Also, my program should NOT contain separate code for each different star please help! ASAP!! | |
Hi guys, I am trying to iterate through a list. This is my code: [CODE] #assume this is the list: list1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] def iter_list(a): for s in a: return s #here it is when it runs: print iter_list(list1) a [/CODE] why doesn't it … | |
Hello there everyone basicly im a new student who has just started studying computing i was wondering if i could make a program to block access to some webpages for example [url]www.bbc.co.uk[/url] so if the user types in [url]www.bbc.co.uk[/url] in the adress bar i want my program to display access … | |
I just want to know if this is done right. And some suggestions on the commented line. [CODE]msg = ... import re msg = re.sub("[^\w ]", " ", msg) names = [] for x in msg.split(): if (x[0].isupper()) and not (x[1].isupper()):# I think this should be done in a different … | |
Hi. I'm new in python and I need some help. I need to make a program that does this: You put in a sentence, then the program puts it in a list. Words can be with one or more spaces; if there are more than one, the program should recognize … | |
Wget is a very useful tool, however, I dont know how to use it in python. Below is my try but with no luck. Would you tell me the right way ? Thank you very much !! I made a wwget.py [CODE] #!/usr/bin/python import urllib2, urllib img=wget("http://blog.freetimegears.com.tw/patrick/archives/Maple-tree.jpg") [/CODE] Running in … | |
Here I am required to use REGEX to do the stock price program, yet I found it almost impossible for me to do, I can only deal with for loop. '''Parse Stock prices. Create a function that will decode the old-style fractional stock price. The price can be a simple … |
The End.