15,181 Topics
| |
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 == … | |
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 … | |
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 … | |
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 … | |
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 … | |
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 = [" "," "," "] … | |
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 = … | |
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 … | |
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 … | |
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 … | |
How can I control the position of text in a label? Thank you | |
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 … | |
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 … | |
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 … | |
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. | |
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 … | |
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 … | |
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 … | |
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 … | |
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. | |
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 … | |
print "Maya Data Out > %s ",pickle.loads(process.stdout.read()) File "C:\Python26\lib\pickle.py", line 1374, in loads return Unpickler(file).load() File "C:\Python26\lib\pickle.py", line 858, in load dispatch[key](self) File "C:\Python26\lib\pickle.py", line 994, in load_tuple k = self.marker() File "C:\Python26\lib\pickle.py", line 874, in marker while stack[k] is not mark: k = k-1 IndexError: list index out of … | |
I'm not really good wih the Big O notation so I was wondering if any one can help me find the Big O notation of this code for each of its function when they are best , worst, and adverage case and a brief explantation of why it's that. Sorry … | |
Dear friends, I need our help for a new task. I have a gps track (sequence of lat long and altitude) and I would like to know if there is a way to make an offset (or a parallel line if you prefer) of this line to its right and … | |
I am writing the following functions I cannot tell where I should leave off with the "bootstrapping" that the first function searchMaze() is supposed to be doing, the wording is not getting through my dense head. searchMaze(maze, start_pos, finish_pos) This function takes a maze data structure as created by readMazeFile(), … | |
Generators are essentially dynamic sequences, making their official debut in Python 2.5. That got me to thinking: can we make a circular list with them? Why yes, we can... | |
You can alternately show one of two lines drawn on the Tkinter canvas by simply moving them on and off the canvas screen. This beats a cumbersome create and delete cycle. | |
Below is a short program I'M working of from udacity.com but I can't figure out why I'M getting the value 6 from the first call to the function. # Define a procedure, biggest, that takes three # numbers as inputs and returns the largest of # those three numbers. def … | |
I need help with a program i am doing. it is a cryptography program. i am given a regular alphabet and a key. i need to use the user input and use the regular alphabet and use the corresponding letter in the key and that becomes the new letter. i … | |
I am using turtle graphics with Tkinter however the problem is that the turtle graphics window comes over my root window and covers it! Is there a way to solve this? Note: i am using turtle inside functions if that makes any difference... import ImageTk import tkMessageBox from Tkinter import* … |
The End.