15,181 Topics

Member Avatar for
Member Avatar for ddanbe

Tadaa! This is my first attempt at writing in Python, trying to solve a good question posed [here](http://www.daniweb.com/software-development/python/threads/32007/projects-for-the-beginner/17#post2016892) #----------------------------------------------------------------------------------------------- # # Python 2.7 # # Calculating area and radius of polygons with known number of sides and the length of this side # Adapted formulas used from this site: http://www.mathwords.com/a/area_regular_polygon.htm …

Member Avatar for vegaseat
1
382
Member Avatar for smandape

I am trying to do some web scraping on [this](http://www.ncbi.nlm.nih.gov/pmc/pmctopmid/) site. So far I have tried the following but the output it gives me is the source code of the site which is different than I expect. I am trying to follow [this](http://nsaunders.wordpress.com/2013/09/17/web-scraping-using-mechanize-pmid-to-pmcidnihmsid/#more-3520) link which has done webscraping in ruby. …

0
167
Member Avatar for farmwife

Here is a plan for a (relatively) random numeric dictionary I've put together. I'm hoping that people can help me refine the plan so that I can start incremental coding: #! usr/bin/env python # creates a random dictionary from random import randint # user inputs maximum length of dictionary # …

Member Avatar for vegaseat
0
215
Member Avatar for marethamogale

write a program that gets a score from a player and rates it based on the following given a score 0-999,the program should display message 'nothing to brag about' 1000-9999 display message 'good score' if score is over 9999 the program should display the message 'very impressive' if score is …

Member Avatar for vegaseat
0
156
Member Avatar for zspoja

I'm learning to use the pyqt libraries and this code won't work (no output): #!/usr/bin/env python2 # -*- coding: utf-8 -*- from pomocni import Ui_MainWindow from PyQt4.QtGui import QMainWindow, QApplication from PyQt4 import QtCore import sys class MainWindow(QMainWindow): def __init__(self): QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) def start(): window = MainWindow() …

Member Avatar for zspoja
0
3K
Member Avatar for João Victor

Just looking for some pointers on how I could improve the code. This is my first game ever and python is my first language so it's bit messy but I'll be happy to explain stuff if needed. Hope you guys can help me out. Here it is: **objects.py** try: import …

0
69
Member Avatar for Taruna_1

Hi, I want to identify the datatypes of the te entire dataframe and group it as String, Number and Date. Required Output: Attributes Datatype A String B Number C String As of now I am using the code: for col_number in range(len(data_frame.columns)): datatype = data_frame[data_frame.columns[col_number]].apply(type).unique()[0] if (datatype is np.str or …

0
113
Member Avatar for mohan.jce

I know to access tasklist of our machine can be done through os.popen('tasklist').read(). Is there any way to read the tasklist (taskmanager data) of other systems connected in a network using Python? Just reading them will be fine. Purpose: Main objective of this is to write a script which will …

Member Avatar for james.lu.75491856
0
240
Member Avatar for nutrion

All, I have this very basic script that's producing some odd output. What I need to do is constantly ping a server, and when/if that server stops responding, I want to write the timestamp and " timed out" to a file. We're trying to lock down a time as to …

Member Avatar for nutrion
0
194
Member Avatar for Rebecca_2

I have a series of (~950KB) '.txt' output files from a computational chemistry program; Each file will contain the line '****optimisation achieved****' at least once and, depending on the result of the calculation, possibly twice. Does the following code, in which I am trying to find specific lines and print …

Member Avatar for snippsat
0
284
Member Avatar for Rebecca_2

I have the following directory/file setup (this is simplified): Ce +---top.txt +---X0.0 | | | +---Y0.0 | | | | | +---X0.0Y0.0Z0.0.dat | | +---X0.0Y0.0Z0.05.dat | +---Y0.05 | | | +---X0.0Y0.05Z0.0.dat | +---X0.0Y0.05Z0.05.dat +---X0.05 | +---Y0.0 | | | +---X0.0Y0.0Z0.0.dat | +---X0.0Y0.0Z0.05.dat +---Y0.05 | +---X0.0Y0.05Z0.0.dat +---X0.0Y0.05Z0.05.dat Within each Y directory, …

Member Avatar for Gribouillis
0
673
Member Avatar for ZBatool

0 down vote favorite I am trying to read float numbers from a Binary file using Struct module and then storing them in numpy 3D arrays.When I run it as an independent script, it works fine.But when I call it as a class's function from another script(after import) it gives …

0
104
Member Avatar for dabasank

I need to retrieve all the filenames ending with .xml extension from all the subdirectories present in a directory and copy those names into a new .xml file.

Member Avatar for vegaseat
0
134
Member Avatar for plasticfood

hi guys, I'm new to python and i can't seem to understand this one line of code right here: distance, coordinates = min([(someFunction(state, coordinates), coordinates) for coordinates in coordinatesList]) coordinatesList contains a list of paired coordinates (x,y). someFunction returns an int. My question is why isn't distance and coordinates contain …

Member Avatar for plasticfood
0
367
Member Avatar for marethamogale

write a program that stimulates flipping a coin 100 times and then displays the total number of heads and total number of tails achieved

Member Avatar for phorce
0
174
Member Avatar for Joseph Vann

Hello, I am working on a Tk program that generates geometric patterns, and I have written into all of my defs that if the variable "outline" is True it will draw a black outline, otherwise it will draw an outline the same as the fill. I tried a function called …

Member Avatar for ZZucker
0
397
Member Avatar for vlady2911

I have a database with the following structure: lat lon id 19.7 -95.2 1 19.7 -94.7 1 19.3 -93.9 1 19 -93.5 1 19 -92.8 1 19.2 -92.6 1 19.9 -93 1 20 -92.8 1 23.1 -100.2 2 23.2 -100 2 23.3 -100 2 23.3 -100.2 2 23.4 -99 2 …

Member Avatar for glez_b
0
149
Member Avatar for Meikell 'Kai'

So! I'm building a GUI for an application I'm currently developing and I'm having a bit of trouble figuring out an issue. I'll try to explain it as best as I can in the code lines. Basically, I built a class to handle the initial window for the program, but …

Member Avatar for Meikell 'Kai'
0
2K
Member Avatar for Gribouillis

The syntax of the [icode]str.format()[/icode] method described in [url=http://docs.python.org/library/string.html#formatstrings]the python 2.6 documentation[/url] looks both powerful and complex. The idea of this thread is to start a collection of nice formatting examples which will ease the task of mastering this function. Please post useful examples, and document them :)

Member Avatar for Gribouillis
3
3K
Member Avatar for RHNation

def main(): #this program calculates the total price of a meal after inputting cost of food #tip and sales tax print ('Welcome to the Meal Calculator Program') print() #get the cost of food using the input function food_cost = input ("Please enter the price of your meal: ") food_cost = …

Member Avatar for vegaseat
0
8K
Member Avatar for ggsr45

Hi, i have this output from a SQL query : new = (('{reason:slash,data:{"SET0":"=SET2"}}',), ('{reason:slash,data:{"""REM_1""": """=0xFF""", """REM_2""": """=0x1""", """SET0:REM_3""": """=SET2:REM_3""", """MREM_4""": """=0xFF"""};{}}',)) I am trying to get it such that i put all these items in a dic in the following manner : {'MREM_4': '=0xFF', 'REM_2': '=0x1', 'REM_1': '=0xFF', 'SET0:REM_3': '=SET2:REM_3'} …

Member Avatar for ggsr45
0
178
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
358
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
231
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
208
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

The End.