15,190 Topics

Member Avatar for
Member Avatar for LinaClark

Hello, I am a newb all the way around and I hope that I explain this thoroughly in order to get the help I need. I have a mysql db inside of my python program that generates a hint. I need to have a random number (which will later be …

Member Avatar for rrashkin
0
207
Member Avatar for bottlecaps

So essentially I'm completely lost with this problem our professor gave us. I was absent for the lecture, and he isn't very keen on uploading the lecture notes before our assignments are due. Anyway, the program to be written goes something like this. We need to write a non-graphical program …

Member Avatar for socialshouting
0
196
Member Avatar for runlevel3nut

I'm self-studying python, and more advanced python programmers have pointed out to me that I'm learning an obsolete instruction set and the use of obsolete tools thanks to being taught about an old version of python rather than the most current one. The website where I'm self-studying also offers chances …

Member Avatar for runlevel3nut
0
287
Member Avatar for knd15

I know this maybe easy but I need help with creating a fibonacci sequence array from a to b. This is my code so far: def FibL(a,b): list = [] if a == 0: return 0 elif a == 1: return 1 else: return FibL(a-1) + (a-2) for i in …

Member Avatar for vegaseat
0
240
Member Avatar for krystosan

I am trying to move the items up and down depending on the call made, so I have came up with this def changePriority(self,*args): crntRow = self.listWidget.currentRow() total=self.listWidget.count() if args[0]=='up': if crntRow > 0 : crntItem= self.listWidget.takeItem(crntRow) self.listWidget.insertItem(crntRow+1,crntItem) if args[0]=='down': if crntRow + 1 < total: crntItem=self.listWidget.takeItem(crntRow) sel.listWidget.insertItem(crntRow-1,crntItem) else: print …

Member Avatar for vegaseat
0
148
Member Avatar for satsujin

Hi folks, I'm trying to use the subsample method in the PhotoImage class to resize an image I have in a list that links to a Label widget in Tkinter but python says there is no such method. I know I could use Image.resize before calling Photoimage but since I'd …

Member Avatar for satsujin
0
3K
Member Avatar for MissAuditore

Hi, My code: Print Y fig = plt.figure(figsize = plt.figaspect(0.5)) ax = fig.add_subplot(1, 1, 1, projection='3d') surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap = cm.gist_rainbow, linewidth=0, antialiased=False) print Y ax.yaxis.set_major_formatter(matplotlib.dates.DateFormatter('%H:%M:%S\n%m/%d/%Y')) #ax.yaxis.set_major_locator(dates.MinuteLocator()) fig.colorbar(surf) plt.show() Result: [[ 1.34503975e+09 1.34503975e+09 1.34503975e+09 ..., 1.34503975e+09 1.34503975e+09 1.34503975e+09] [ 1.34503980e+09 1.34503980e+09 1.34503980e+09 ..., 1.34503980e+09 1.34503980e+09 …

0
82
Member Avatar for jkembo

Hello everyone, I need some help, I would like to merge two cells together within a row only (e.g) in a CSV file using python. So far, I have 4 columns in the file, but now I would like to merge two cells in one, but I don't have any …

Member Avatar for jkembo
0
13K
Member Avatar for SoulMazer

Hi all, I'm working on a (Python) program which, in short, is a threaded TCP socket server which creates a new "tab" in a wx.Notebook widget for every incoming connection it sees. I've run into a strange problem where when I call notebook.AddPage(...), one of three things happens: 1. A …

Member Avatar for Gribouillis
1
731
Member Avatar for hotblink

Hi, I'm studying for a final exam and I just wanted to ask if you could be so kind to explain how you get these answers from these questions. I'm really confused on them. Thanks! 1) What is the output of the following program? def f(x, y): if y == …

Member Avatar for Xantipius
0
138
Member Avatar for dp121307

I tried to use a different forum but I was completely out of my league with the responses. I am extrememly new to python. As a project, I'm supposed to ask the user to input a file name, check that the file exists, output the numbers in the file, and …

Member Avatar for vegaseat
0
20K
Member Avatar for Jezza25

Hi I know how to import a individual file def cvt(s,default=-1): try: return float(s) except ValueError: return default import csv with open("Dealer1.txt", "rb") as csvfile: reader = csv.reader(csvfile, delimiter="\t") data = list(reader) I have a folder that contains 50+ files, using Glob, I created the following code import os import …

Member Avatar for Gribouillis
0
225
Member Avatar for Jezza25

Hi I have a script that is looking up multiple files, the files have a consistent layout they are a notepad from a CSV file. In some files there is a number and in some files there is a text. i have created a dictionary that one of the items …

Member Avatar for TrustyTony
0
110
Member Avatar for woooee

The problem is explained by the comments in the code. It is a fundamental question about the method call...every time I try text_box_name.tk_textBackspace() I get the TclError message. That's why I asked the question without the code... # When user enters a search word in the +search_box' text widget and …

Member Avatar for woooee
0
285
Member Avatar for aVar++

Hello, i have my naughts and crosses code as pasted below. Can someone help me with code to recognise if the game has come to a draw and recognising any invalid moves. Row1 = [" "," "," "] Row2 = [" "," "," "] Row3 = [" "," "," "] …

Member Avatar for slate
0
178
Member Avatar for MissAuditore

Hi guys, Trying to learn more about pandas csv reading. I have a file, with date and time on first row and a lot of data below. I want to be able to slice the data from T1 to T2 and use it for something. fname = "C:\Users\zana.pepaj\Desktop\Temperature.csv" data = …

Member Avatar for MissAuditore
0
188
Member Avatar for Jezza25

Hi Can I get some assistance with the following Code: Letter = raw_input("Enter Letter") A = 7 B = 8 C = 9 print Letter I have left the basic info but if the Letter A is entered in the print Letter it results A, I want it to give …

Member Avatar for Jezza25
0
99
Member Avatar for efwon

so I am new to python and I am trying to generate a 100 numbers from 0 to 10 and find out how many times a three appears. I'm not sure exactly how to get it to work. I basically just want to be able to count how many times …

Member Avatar for snippsat
0
232
Member Avatar for runlevel3nut

I'm returning to college after a 21-year absence and am starting fresh in a science stream. My first course in January will be the introductory Python course. In the meantime, I'm doing the Codeacademy tutorials and have completed the basic ones on variables, strings, comments, conditionals, some functions, and a …

Member Avatar for runlevel3nut
0
245
Member Avatar for slasel
Member Avatar for Lardmeister
0
107
Member Avatar for aVar++

I have got a simple naughts and crosses game working, can someone tell me a simple def blah(): .. command to check if the player has already moved to a place on the board already taken.. E.G Player's first go = top left Player's second go = top left.. (message …

Member Avatar for aVar++
0
122
Member Avatar for aVar++

Hey guys, i have been working on this for a while and global doesnt seem to be doing anything; help? Row1 = [" "," "," "] Row2 = [" "," "," "] Row3 = [" "," "," "] Grid = [Row1,Row2,Row3] x = False def NAC(): def check(): #only using …

Member Avatar for aVar++
0
287
Member Avatar for krystosan

I want to know how to check if the string given is a path with a file name or not , the file name with extension is not on disk but will be created later, but since its not created I cannot use os.path.isfile(filepathsupplied) so how should i check if …

Member Avatar for Gribouillis
0
127
Member Avatar for Gribouillis

This snippet is easy: it defines an immutable wrapper around a sequence type (list, deque, etc) which allows a class, function or module to expose a read only version of a sequence to the outer world. A constant wrapper around mapping types could also be defined in a similar manner.

Member Avatar for Gribouillis
2
577
Member Avatar for biscayne

I'm trying to find a record in a csv file in a nested stucture: for elem in lstLine[1:]: for item in open(fname): lstData = item.rstrip('\n').split(';') andexfield = lstData[0] if andexfield == elem: do bladibla Now I want ot add error handling: if no record in fname is found where andexfield …

Member Avatar for Gribouillis
0
276
Member Avatar for satsujin

Hi folks, I was wondering if there was some way to delete all Labels from a Tkinter canvas in one go. I'm not even sure if the labels are being drawn on the canvas since you only use the master(self.root) when creating it but I do the same for buttons …

Member Avatar for satsujin
0
2K
Member Avatar for jlh070945

I'm working through Python Programming by Zelle. I've entered the code for the racquetball problem in Chapter 9 exactly as written in the text. (At least I think so.) The program returns one game only then quits. I've prototyped and unit tested but can't find my mistake. Any insights would …

Member Avatar for woooee
0
145
Member Avatar for WhiteTulip

Hi! I'm writing a program that will take a an inputed phrase, assigns each letter to a picture of the letter from a file, and outputs the given phrase, looking like a ransom note. I have a start, but I'm not really sure where to go next. I've only just …

Member Avatar for woooee
0
310
Member Avatar for vegaseat

This Python code allows you to get selected statistics of a story text. It will count lines, sentences, words, list words and characters by frequency, and give the average word length. It should be easy to add more statistics using the dictionaries created.

Member Avatar for Ene Uran
3
802
Member Avatar for satsujin

I am trying to write a python app that will switch between two views when I click on the canvas in Tkinter. I have written the views and main app as seperate objects with binds linked to the opposing view through the left mousebutton. When I run the app in …

Member Avatar for satsujin
0
189

The End.