15,179 Topics

Member Avatar for
Member Avatar for elbert.leach

# This program reads numbers from a file into a list. def main(): # Open a file for reading. infile = open('text.txt', 'r') sentences = infile.readlines() # Read the contents of the file into a list. infile.close() # Close the file. index = 0 # Convert each element to an …

Member Avatar for Ene Uran
0
324
Member Avatar for silversonicaxel

hi, just a simple question on a wx.TextCtrl element. i have this text field where on an application, where the user can add a string on it. i want a text field with a red text on it. so i've generated this code: self.hRepositoryTextfield = wx.TextCtrl(self.hPanel) self.hRepositoryTextfield.SetDefaultStyle(wx.TextAttr(wx.RED)) if the user …

Member Avatar for Ene Uran
0
338
Member Avatar for slasel

I want one picture to be displayed in the canvas then the another to be displayed in the canvasafter 2 seconds. i used time.speed(2) and canvas.delay(2000) but nothing works! Any help please?! import ImageTk import tkMessageBox from Tkinter import* from turtle import * import time root = Tk()#main window canvas …

Member Avatar for Ene Uran
0
430
Member Avatar for krystosan

I implemented whole UI and logic into one py file now I thing it would be good if I separate the UI file from the logic, and to run the UI I shoud run the file that contains logic that inturn loads the UI... I have `RenderUI.py` module that contains …

Member Avatar for krystosan
0
954
Member Avatar for slasel

Hello, I need help with creating 6 buttons can I do that using some loop and how can that be done? each button has a different image and different text...their bg, and dimensions are the same Also after creating all the buttons I want to make a callback function for …

Member Avatar for slasel
0
280
Member Avatar for slasel

I have a problem...how can i arrange widgets inside a frame using grid? I get all sorts of weird results with widgets coming over each othe

Member Avatar for slasel
-1
76
Member Avatar for pinbustersrule

I've just started using python in my computer technology class. One thing I can't figure out is how to have python put the lists inside a string into alphabetical order. If anyone has any easy answer, it will be much appreciated. Also, my teacher told me he would give extra …

Member Avatar for noonecares
0
886
Member Avatar for giancan

Dear friends, sorry for my ignorance about python containers but I have the need to store (and access) 4 different values per file in folder, namely the filename (with its path) and 3 other values (string or None). When I access the database, I will need to know the 3 …

Member Avatar for ZZucker
0
320
Member Avatar for vegaseat

Comparing a number of different approaches to finding the closest pair of numeric elements in a list. The timing is done with the mpmath module, but you can also use Python module timeit.

Member Avatar for Lardmeister
5
745
Member Avatar for biancairis93

I have to create a class of Persons that will hold information about their name,age,NI number.These details are read from a file that would look like : 55512 Bart Simpson 45 45622 John Smith 58 46231 Alicia Sands 27 My duty is to read each line from this file and …

Member Avatar for Lardmeister
0
125
Member Avatar for elvis1

Hi I am a Pyth noob and wanted to import a text file .To each line of the text file , assign a (fixed) name and sum a number (in increments of 1 from the first line to the last)using the while command for an assigned name. Lets say I …

Member Avatar for noonecares
1
3K
Member Avatar for rmbrown09

I'll keep the story short here but to sum things up: I have always liked computers. Hardware has always been my thing. I have my own custom built desktop and love changing and messing with it every day. I also work (part time) as an IT guy for small business. …

Member Avatar for rubberman
0
231
Member Avatar for jecelone

There are websites such as http://www.cars.com that provide information about secondhand vehicles. Design a base class for vehicle with fields such as model, year, total mileage, vehicle identification number (VIN), EPA class, EPA mileage, engine, transmission, and options. Design subclasses for car, truck, SUV, and minivan. Think about the specific …

Member Avatar for TrustyTony
0
99
Member Avatar for andy_piles

I want to write a client-side code that makes a HTTP Request using urllib2 functions. The server side code should make an appropriate respone to the HTTP Request.

0
58
Member Avatar for _Fletcher

I'm having some trouble with vpython for my first-year programming project. The code below is a solar system simulator and I'm having issues with pausing animations and restarting them. I also tried to add a feature where if you click on a planet it will refocus the camera on the …

Member Avatar for andrewie101
0
231
Member Avatar for inaxassan

The human body has many organs (heart, lungs, brain, and kidney, to name a few). We could think of the human body as complex object made up of simpler objects (organ). a) Create classes for heart and brain. Think about what the functions of the heart and brain are in …

Member Avatar for TrustyTony
0
293
Member Avatar for vegaseat

Python is entirely object oriented and using classes is made relatively simple. Beginners have a certain angst when it comes to using classes. There is a hump in the learning curve, which I like to overcome with this example. Inheritance really makes sense and saves you a lot of extra …

Member Avatar for Ene Uran
0
1K
Member Avatar for vegaseat

An approach to create multiple GUI buttons (or other widgets) using list comprehension. In this case I used the Tkinter GUI toolkit that comes with the Python installation.

Member Avatar for Ene Uran
2
481
Member Avatar for krystosan

how do i make use of seticon inherited by QCheckBox to display icon with exclusive checkboxes i found a link here but doesnt have any example how to do so http://riverbankcomputing.co.uk/static/Docs/PyQt4/html/qabstractbutton.html#setIcon

Member Avatar for krystosan
0
165
Member Avatar for JohnnyBoy324

I'm assigned a project in which i have to write a program that simulates the game of hangman using classes and GUIs. I'm really stumped on how to organized it into classes. I know that i want the word that is to be guesses to come from a list and …

Member Avatar for Lardmeister
0
25
Member Avatar for ailen.samson

Hi everyone. I am having a hard time modifying this code, I'm really new to python and I am trying to find the closest pair among the 10 input integers from a user. Here's my code so far and there is a syntax error... a = [0,1,2,3,4,5,6,7,8,9] a[0]=input() a[1]=input() a[2]=input() …

Member Avatar for woooee
0
895
Member Avatar for Carlsn

I need help with creating a program that produces a daily report for a store. I'm really bad at computer science so I'm not even sure where to start on this! Here are the instructions: Write a Python program to accomplish the following. Use modular design. Include at least 3 …

Member Avatar for woooee
0
654
Member Avatar for MissAuditore

Hi, Have a csv-file with time as heading for each column and first column with depth and temperature inbetween. n*m table, or plot. I'm having problems reading the csv file: fname = r'C:\Users\Desktop\Temperature.csv' T1 = '15.08.2012 16:09:10' T2 = '15.08.2012 19:22:57' initial = time.mktime(time.strptime(T1, "%d.%m.%Y %H:%M:%S")) final = time.mktime(time.strptime(T2, "%d.%m.%Y …

Member Avatar for rrashkin
0
203
Member Avatar for thakkarpranav

Hi, I have a Python code that uses google app engine to get data via a html page. I need to modify the Python code and write a PHP code, so that the PHP code is able to pass on the required data, which is two numeric values, directly to …

0
81
Member Avatar for Sudo Bash

Hi all, I am fairly confident with Python, and am now turning my focus from learning how to program the language to learning to program it well. I am wondering what the best way to approch classes which have too many variables in them. I an writing a platformer game, …

Member Avatar for Sudo Bash
0
250
Member Avatar for june.pierre.311

I'm writting a program that will take a file as input and go through the list of numbers in the file and return the max number uing recusions. I'm not very good with recursions here is what I have so far. Also I'm not allowed to use the max command. …

Member Avatar for vegaseat
0
330
Member Avatar for pxalpine

Is there a way to read in a two-columned CSV file, and based on the fields in 1st column, output many different files? The input/output looks something like: input.csv call Call Mom. call Call T-Mobile. go Go home. go Go to school. go Go to gas station. play Play music. …

Member Avatar for rrashkin
0
195
Member Avatar for Delightfully

Hello All!! I have an assignement that I am working on and for some reason I cannot for the life of me recall how to do something so simple lol. The directions are too "Write a function named Exam, which takes one argument n where n>2. Your function creates a …

Member Avatar for Lucaci Andrew
0
309
Member Avatar for siaosituimoloaublood

i am in need of help with this homework. The instructions are as followed: Package Newton's method for approximating square roots in a function named newton. This function expects the input number as an argument and returns the estimate of its square root. The script should also include a main …

Member Avatar for TrustyTony
0
5K
Member Avatar for johnathan.millsap

#Guess the number game by Johnathan Millsap import random guessesTaken = 0 print('Hello! What is your name?') myName = input() number = random.randint(1, 100) print('Well, ' + myName + ', I am thinking of a number between 1 and 100.') print('Try to guess it!.') while guessesTaken <= 3: print('Take a …

Member Avatar for vegaseat
1
1K

The End.