15,181 Topics

Member Avatar for
Member Avatar for checker

[CODE]reader = csv.reader(open('new_mondy_csc_data_revise.csv'), delimiter=',', quotechar='"') header = tuple(reader.next()) print "%-14s|%-10s|%-5s|%-5s|%-11s|%-11s|%-11s|%-11s|%-11s|%3s" % header # read header line from csv print "-" * 45[/CODE] There are a total of 10 fields in the header across a csv file I want to print the first three instead, how can I do that?

Member Avatar for checker
0
101
Member Avatar for wildplace

self.button1 = Button(root, text = '1', \ command = self.buttonAction) self.button1.grid(row = 1, column = 0) self.button2 = Button(root, text = '2', \ command = self.buttonAction) def buttonAction(self): if self.button1 [COLOR="Red"]is clicked/pressed... [/COLOR]: value = 1 how do i express the word in red in python code?!!?? thanks :D

Member Avatar for lrh9
0
126
Member Avatar for Tech B

Thought someone might like this little script. Its an animated wallpaper. You'll need to draw the frames though. I used Windows paint to make the frames. I drew two stick people fighting. You'll need to know the basics about animation. I saved each picture as .bmp It worked with .jpg …

0
934
Member Avatar for Skrutten

I wonder how the random.normalvariate function works. When I do the method below, I end up with negative numbers. I don't want that. How do I prevent that? And also, i want 10 numbers, but it always turn out 9 and a "none". What is none? How can i remove …

Member Avatar for vegaseat
0
182
Member Avatar for Adam2k

Hi guys! I need your help with a simple program I'm trying to make. It's supposed to read values from a file, covert them (and add/multiply), sort, and then view the values to the user. The values looks like this: [code]Stockholm 650000 55.5 2100 08 123 456 Whateverstreet 123 ... …

Member Avatar for Adam2k
0
109
Member Avatar for Graxxis

hello, long time lurker first time poster! currently writing a program that generates 100 random integer values in the range of 1 - 50, then displays how many of those numbers are in the range 1-10, 11-20 etc etc. i generated the numbers with no problem, but im not too …

Member Avatar for hondros
0
96
Member Avatar for chris99

[CODE]global Num1 from Tkinter import * Num1 = "" def buttonNPush(n): global Num1 Num1 = Num1+n print Num1 def clearScr(): global Num1 Num1 = "" root = Tk() textbox = Entry(root) textbox.pack(side=TOP) #Create Frame with buttons numbered 0-9 frameButtons = Frame(root) frameButtons.pack(side=LEFT) button1 = Button(frameButtons, text="1", command=buttonNPush("1")) button1.grid(row=0, column=0) button2 …

Member Avatar for vegaseat
0
207
Member Avatar for Skrutten

I'm trying to use my methods, but i always get " <bound method Deltagare.tavla of <__main__.Deltagare instance at 0xfba58>>" what does it mean? is something wrong with my class?

Member Avatar for hondros
0
101
Member Avatar for faded jeans
Member Avatar for lrh9
-2
63
Member Avatar for mahela007
Member Avatar for RogerI

I need to read in a large amount of data from a csv file into arrays. I am using Numpy as I need to later manipulate and plot the results. I have decided to use numpy.loadtxt as this appears to be the most efficient method to read in the data. …

Member Avatar for RogerI
0
2K
Member Avatar for checker

[CODE]class Database(Student): def __init__(self): g = [] choice = ['Basketball','Football','Other','Baseball','Handball','Soccer','Volleyball','I do not like sport'] data = student.sport k = len(student.fname) print k freq = {} for i in data: freq[i] = freq.get(i, 0) + 1 for i in choice: if i not in freq: freq[i] = 0 for i in …

Member Avatar for checker
0
205
Member Avatar for SoulMazer

Okay, well I've been looking for at least an hour now for some straight-forward python-xlib documentation, and I have been unable to find any. Luckily...I have quite the easy problem. If somebody would be able to help me create a simple script that would say "Hello" every time the left …

Member Avatar for SoulMazer
0
564
Member Avatar for ahspats

How could one find the length of longest row of same elements in a list. For example if i have a list list = [0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1] and i …

Member Avatar for woooee
0
139
Member Avatar for takarii

Ive written a program to do with drawing a line from a centre point and it is meant to snake randomly from the centre. However, it seems to be incredibly biased as to where it decides to go. the 4 directions are as simple as up down left and right, …

Member Avatar for takarii
0
119
Member Avatar for ffs82defxp

I don't understand what those two things do and how they work i tried researching off google, but i couldnt get a direct answer

Member Avatar for vegaseat
0
775
Member Avatar for ribot

Hi! I'm trying to combine some frames in a GUI as a toolbar and content area. Currently I'm on windows and using python 3, and I want preferrably my app to work on *nix and mac as well. The problem is that in the following app, when I resize it …

Member Avatar for ribot
0
2K
Member Avatar for qq263020776

A building has three elevators, 16-storey level. Write a program to simulate the operation of elevators. Requirements: 1. At the highest level can only be a downward trend, the lowest level can only be upward, the middle layer can be by any upward and downward; 2. Each layer is only …

Member Avatar for vegaseat
-3
1K
Member Avatar for jwxie

[CODE]import csv class Reader(object): def __init__(self): self.names = [] self.idigit = [] self.fileReader_list=[] self.fileReader = csv.reader(open("survey_result.csv", "rb")) self.fileReader_list.extend(self.fileReader) for column in self.fileReader_list: self.names.append(column[1]) self.idigit.append(column[2]) del self.names[0] del self.idigit[0] X = Reader() for i, names in enumerate(X.names): print names, X.idigit[i][/CODE] Ch, Sbb 6748 Oudfd, Sufdfdfy 8473 Sdfdfu, Radfdf 5667 Adfn, Mudfmmdfd …

Member Avatar for snippsat
0
152
Member Avatar for pluring

Hi! I need to split a list if item A is followed by item B. I'm really stuck at this and the only thing i could think of is that i should use regex, but i dont know how. Example of list: list = ['email@email.com', 'email@email.com', 'email@email.com', 'REF123', 'REF123', 'email@email.com', …

Member Avatar for Namibnat
0
104
Member Avatar for i are smart

i just started learning GUI, and i made my first graphic interface using the tkinter module, but as information is piled up and goes beyond the window's dimensions, i need those scroll bars to up and down

Member Avatar for woooee
0
99
Member Avatar for i are smart
Member Avatar for ffs82defxp

I noticed that when i posted programs on here people gave me their versions, and had [CODE] import * def somethng_here(): while True: Try: pass except ValueError #or some other types of things liek that [/CODE] I don't understand how a function can be FALSE, as well as how these …

Member Avatar for vegaseat
0
329
Member Avatar for lrh9

Lately I've been writing a lot of code involving the creation of new objects, and I quickly come to find that Python almost always creates a reference to an object instead of a new object. I understand the importance of conserving memory usage, but in this instance I actually need …

Member Avatar for lrh9
0
186
Member Avatar for lidyaMikhail

hello i have a python chat server (multi client) and i wanted to connect a java client to it but i have been searching alot about java-python connection and i got solutions like using APIs as YAML or SOAP but i just can't figure out which one or if there's …

0
49
Member Avatar for MRWIGGLES

can anyone help me determine it? from the looks of pages on google. it's just a bunch of 90 degree angles that are constantly rotated 45 degrees about it's axis. thanks.

Member Avatar for vegaseat
0
1K
Member Avatar for newtri13

I have a small script that connects using ssh and opens a tunnel on port 3306. It works in the ipython interpreter if i type it in manually. However when I try to run the script from the interpreter or command line I get the error message "Can't connect to …

Member Avatar for newtri13
0
181
Member Avatar for hondros

Okay, this is what I am trying to do. I am attempting to create my own encrypter. I have the base encryption running, used just to encrypt a string you put in. I am going to add functionality to open a text file's contents and encrypt them, outputing them into …

Member Avatar for vegaseat
0
161
Member Avatar for goisagi

So my listname is men =[] How can i print just the 10 first elements of the list? It contains 15... And it's a matrix... I thought about making a while-loop while i > 9: but it didn't work. Can anybody help me please? :)[code]for gender in men: print gender[0] …

Member Avatar for goisagi
0
96
Member Avatar for El Duke

I can't believe I am getting this error again and again .... Here is my class: [CODE]class LANGUAGE: def __init__(self, val): self.val = val def Set(self): return self.val [/CODE] Here is the function call: [CODE]if text in translate._languages: msg = "You have chosen the " + translate._languages[text] global NewLang newlang …

Member Avatar for El Duke
0
675

The End.