15,190 Topics
![]() | |
From http://pymbook.readthedocs.org/en/latest/modules.html I've added some code to this code to make a little header for my code snippets as an exersise. """ Bars Module ============ This is an example module with provide different ways to print bars. """ def starbar(num): ''' (int) -> integer Prints a bar with * >>> … | |
I can't find anything to help me out on this method of sorting. How do I do it? | |
hi to all i want to use c program in python or in other way i want to run c program from python | |
def main(): print ('Welcome to the mpg calculator program') print() #get the miles driven using the input function miles_driven = input ("Please enter miles driven: ") miles_driven = float (miles_driven) #get the gallons used using the input function gallons_used = input ("Please enter gallons used: ") galons_used = float (gallons_used) … | |
develop a program which asks for a name and a password,and prints an acceptance message if the name is "aladdin" and the password is "sesane".the program should print a reject message in all other cases.this should be achived by combining the two tests into one using the "and"key word | |
This error frustrates me when I want to iterate over the elements of a set, for example when trying to convert the set to a list. How do I get around it? | |
Hi guys, I need some help with lists or dicts. I have a list with 2 columns like this "123.04 241.30","232.00" [and so on for about 400 lines] and another list which is more complex: "val1","val2","val3","nnn.nn nnn.nn","232.00" (where "n" is a number) [some thousands lines] Now I want to compare … | |
Hey guys, I am new here and have found many answers to my problems from this website so I figured it was time to join. Here's the deal: I have just started trying to learn Python through MIT's OpenCourseWare. I am currently on PS1a (Problem set 1a) and am having … | |
As I've learned more about basic console Python script writing, I've had a look at both Tkinter and GTK+...and, at first glance, I like GTK+ better. Which do you guys prefer, and why? | |
![]() | Hi, I have a quick, and what seems like very stupid question. I have a list of files in a directory with various extensions. I want to open only the ones with the extension '.txt'. I have got as far as finding them (and can print their filenames to a … |
hi guys !!! i want to make an web browser in python , as my college project . what i'm looking for is guidance , on how to make it and which module's shall i use . currently i'm planning to use webkit and gtk+ to obtain my goal. secondly … | |
Hi. if I want to use the for loop to make multiplication table for the number 3 in sequence. For ex; when I excute the for loop, I want the user to enter intger "3" and then it start to question 3x3, to the user and up if they did … | |
Hi everyone I am learning python, I came across a sample program which checks whether the given number is prime number or is not a prime number using **for loop** and **range()** function. I can't understand that program, can someone please help me understand it? Here is the program and … | |
Using the PySide GUI toolkit will make selecting, copying and pasting encrypted and decrypted text somewhat easier. Not ideal yet, but it will be a good start for those of you who are not very familiar with GUI programming. | |
I am trying to make a save feature in a game so that a player could save, then quit the game, then open the window again to select proflie and play from when they left off. Thanks!! | |
![]() | Hi, I am very new to programming but am hoping it will be able to speed a few things up for me. However I am struggling to work out how to write a Python3 script that does the following and am wondering if you could help me out. I have … |
I tried downloading the file and playing it using `winsound` to play it with the flag `SND_MEMORY`, but it only accepts `str` instead of the `bytes` object I got from `urllib.request.urlopen`. Using `decode()` needs a valid encoding, but I don't have one. CLARIFICATION:downloading the file I mean as using `urllib.request.urlopen` … | |
Hello , I am making tries to display images in different tkinter windows , in every window displaying a different image , for this i made this code : # -*- coding: cp1252 -*- from Tkinter import * import Tkinter as tk import ttk from PIL import ImageTk, Image import … | |
This short snippet shows you how to preprocess a text to remove punctuation marks, then do a word frequency count using Counter() from the Python module collections. Finally, two sorts are applied to display words with matching frequency in alphabetical order. | |
I am still new to programming and hoping someone can point me in the best direction. I am creating a script that monitors a directory and creates a zip file and then mails the archive. I have successfully monitored the dir and can zip the files. I am somewhat lost … | |
I started learning about Python 15 days ago and I'm a little bit confused whether it is a programming language or scripting language. I am thinking it is a programming language because it contains Exception, RE, Networking etc. However I thought scripting languages could not contain features like Networking,Exception etc. | |
The code shows you how to create a persistent to file dictionary of data using the python module shelve. | |
i have been looking around and its hard to find what i want. I am able to add context menu item to a FOLDER by doing this: [HKEY_CLASSES_ROOT\Directory\shell\Command] @="TestRightClick:" [HKEY_CLASSES_ROOT\Directory\shell\Command\Command] @="myExe.exe %1" I need to have "context menu for all the files in folders of a particular directory". context menu … | |
I am trying to add a custom widget dynamically, multiple times. However, the widgets just stack up in the same place. I have tried several combinations of Layout() and Fit() and setSizerAndFit() after adding custom widget to the sizer Thank you for any help #!/usr/bin/env python # -*- coding: US-ASCII … | |
num_trades = int(input("Number of trades for today?")) for i in range(1, num_trades + 1): action = input("Trade number", i ,"(buy/sell)?") num_shares = int(input("Number of shares to buy?")) price_per_share = float(input("Price per share?")) I'm getting a TypeError on the line "action = input("Trade number", i ,"(buy/sell)?")" Help Thanks | |
I have an integer dataframe and in my code I am doing some length calculation( which can be only perfomred on string), therefore I need to convert my dataframe to String. I have tried using str(), its not helping me, it would be helpful if you could suggest something. | |
I saw this code on stack overflow def writeProfile(profileName, profileData): """ pickle user profile data """ os.chdir(PROFILE_DIR) fileName = profileName + ".dat" f = open(fileName, "wb") pickle.dump(profileData, f) f.close() os.chdir("..") It is for saving progress under the pickle module. I don't see a way to save variables. How would I … | |
Which of these is the best practice for executable Linux scripts: #! usr/bin/env python #! usr/bin/python #! usr/bin/env python3 #! usr/bin/python3 All four of them work just fine on my system, so I'm looking for the best practice. Thanks. | |
This code: def reverse(x): for i in range(len(x)): y[i] = x[-(i+1)] return y a = [1, 2, 3, 4, 5] b = reverse(a) returns a "global variable 'y' not defined" error. WHAT GLOBAL VARIABLE????? If I add 'y = []' anywhere in the code, either inside the function or outside … | |
I had a function all by itself in the file [filename].py, and the file was properly executable. This is how people advised me to call it externally: import func func.[filename]() But I was getting errors all over the place. So I contacted Python help and they told me something different, … |
The End.