15,179 Topics
| |
# 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 … | |
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 … | |
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 … | |
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 … | |
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 … | |
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 | |
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 … | |
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 … | |
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. | |
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 … | |
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 … | |
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. … | |
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 … | |
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. | |
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 … | |
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 … | |
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 … | |
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. | |
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 | |
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 … | |
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() … | |
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 … | |
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 … | |
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 … | |
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, … | |
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. … | |
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. … | |
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 … | |
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 … | |
#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 … |
The End.