15,190 Topics

Member Avatar for
Member Avatar for lucpet

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 * >>> …

Member Avatar for lucpet
0
212
Member Avatar for chris99
Member Avatar for farmwife
0
6K
Member Avatar for Ankurjain123

hi to all i want to use c program in python or in other way i want to run c program from python

Member Avatar for vegaseat
0
360
Member Avatar for RHNation

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) …

Member Avatar for farmwife
0
300
Member Avatar for onalenna.bobeilwe

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

Member Avatar for farmwife
0
232
Member Avatar for farmwife

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?

Member Avatar for farmwife
0
7K
Member Avatar for giancan

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 …

Member Avatar for giancan
0
344
Member Avatar for Dunkler

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 …

Member Avatar for Ashley_4
0
209
Member Avatar for farmwife

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?

Member Avatar for farmwife
0
4K
Member Avatar for Rebecca_2

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 …

Member Avatar for vegaseat
0
226
Member Avatar for thecreator232

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 …

Member Avatar for slate
0
464
Member Avatar for amrX

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 …

0
51
Member Avatar for Varunkrishna

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 …

Member Avatar for lucpet
0
939
Member Avatar for vegaseat

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.

Member Avatar for Lardmeister
2
526
Member Avatar for Jacklittle01

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!!

Member Avatar for james.lu.75491856
0
426
Member Avatar for Rebecca_2

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 …

Member Avatar for Gribouillis
0
330
Member Avatar for james.lu.75491856

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` …

Member Avatar for snippsat
0
1K
Member Avatar for Ismatus3

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 …

Member Avatar for Ismatus3
0
5K
Member Avatar for vegaseat

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.

2
668
Member Avatar for crag0

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 …

Member Avatar for Gribouillis
0
362
Member Avatar for estetik23

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.

Member Avatar for <M/>
-3
215
Member Avatar for vegaseat

The code shows you how to create a persistent to file dictionary of data using the python module shelve.

Member Avatar for Gribouillis
4
884
Member Avatar for mohan.jce

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 …

Member Avatar for mohan.jce
0
235
Member Avatar for Fcasualty

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 …

Member Avatar for Fcasualty
0
301
Member Avatar for zswinford

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

Member Avatar for sepp2k
0
14K
Member Avatar for Taruna_1

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.

Member Avatar for Taruna_1
0
3K
Member Avatar for Jacklittle01

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 …

Member Avatar for Gribouillis
0
245
Member Avatar for farmwife

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.

Member Avatar for james.lu.75491856
0
242
Member Avatar for farmwife

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 …

Member Avatar for james.lu.75491856
-1
176
Member Avatar for farmwife

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, …

Member Avatar for farmwife
0
176

The End.