15,175 Topics
| |
Dear all, I wrote 2 scripts and at a certain point of the first I would like to run the second, and when the second is done, to go back to the first and continue with it. How can I do it? I put at the desired point of the … | |
I'm trying to find degrees of separation between any two actors in a movie database. I succeed when I reach my base case, which is 1 degree of separation (i.e. actor is in same movie as another actor) but I use recursion to find all other degrees of separation, and … | |
I have written almost all of my program, except I am stuck on this certain part. I need to write an averege out to figure all students final grades out as a statistic of the course. Students name and final grade have been appended to an external file(keep in mind … | |
I just completed an assignment, and both scripts function the same ultimatley, but just wanted to know if there were any potential differences, or is it just a matter of style? [CODE] if num % 2 ==0 : new = num //2 num = new print(num) count = count +1 … | |
Hi, I am using the command in python from a linux system: [CODE=python] import os os.system('grep "^[0-9]" data.txt | wc -l') [/CODE] The output of this is an integer like 115. Can I assign this to a variable somehow? For example: x=os.system('grep "^[0-9]" data.txt | wc -l') DOES NOT WORK. … | |
Hey guys I need some help with making the iframe be dynamic with the webpage. it is in video_page and I cant seem to get around it. here is the code: [code] def video_page(self): return """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" … | |
Hi - I know that this has been somewhat discussed in a couple of threads, but I haven't seen anything with an actual answer. What would the design or pseudocode look like? Write a program that checks HTML files to determine whether the embedded XHTML tags are balanced. The program … | |
I've been asked to write a program that computes the nth Fibonacci number where n is a value input by the user. For example, if n = 6, then the result is 8. This is what I have so far: def main(): print "This program will compute nth Fibonacci" print … | |
Hi,I was wondering how to read and write strings in python. I have this code where I'm creating a path, but its a string, and now I want to write to this string. But keep getting this error message [I]AttributeError: 'str' object has no attribute 'write'[/I] I was thinking about … | |
Hey, I'm new to Python programming and I've been making a simple rock paper scissors program for practice. I've managed to get it working; it asks the player to enter 'a' for rock, 'b' for scissors or 'c' for paper. If the player entered a, b or c, a number … | |
..uhm...hello...i'm new to python programming and I really want to explore more about this... ...i just want to know what is the best compiler I can use for this... | |
how can i compare 2 string for bull hit game in python. i wrote the program itself. how can i find how many hits and bulls i have. [CODE]import string import random import re m = input (' Please input the long of the string you want to guess :') … | |
Hey guys, I need to print a dictionary from a text file and than print it again with the last two values updated in each row. The text file appears as so: 12345678 Joe Dokes IT 30 95 87654321 Sally Sue ISYS 50 87 34876293 Bo Burnham MATH 60 78 … | |
I need to write a small bit of code that will print an error if I cannot resolve the name to IP. I see that you can use the "socket.gethostbyaddr" methods but I cant seem to find a simple method/exception for when it does not find an IP address. Also … | |
Hi every body. I want to make a topographical image from a 2d Aerial photograph. how can I do it in python? Thanks if help me. | |
Hi, i'm python beginner. how to make that only use def, for, list, while .. [CODE] def comb(n,r): if r == 0: return 1 elif r == n: return 1 else: return comb(n-1,r-1) + comb(n-1,r) [/CODE] this code is very slow.... ah , I have to use recursion .! please … | |
Task: • Create a text file with 5 questions in it. • Read each question in from the file. • Ask the user for their response. • Create a new text file. • Write the user’s answers to the text file. • Ask the user if they’d like to review … | |
Hi all - I need to write a code that reads in a 20 line file 4 lines at a time, and puts the five sets of 4 strings into their own individual strings. So there should be five strings containing 4 strings each. I am very confused and havne't … | |
Hi all, I have text file as follows... >s1 MPPRRSIVEVKVLDVQKRRVPNKHYVYIIRVTWSSGATEAIYRRYSKFFDLQMQMLDKFP MEGGQKDPKQRIIPFLPGKILFRRSHIRDVAVKRLIPIDEYCKALIQLPPYISQCDEVLQ FFETRPEDLNPPKEEHIGKKKSGNDPTSVDPMVLEQYVVVADYQKQESSEISLSVGQVVD >s2 MAEVRKFTKRLSKPGTAAELRQSVSEAVRGSVVLEKAKLVEPLDYENVITQRKTQIYSDP LRDLLMFPMEDISISVIGRQRRTVQSTVPEDAEKRAQSLFVKECIKTYSTDWHVVNYKYE DFSGDFRMLPCKSLRPEKIPNHVFEIDEDCEKDEDSSSLCSQKGGVIKQGWLHKANVNST . . . I wanted to count letter 'P' in each sequences output should be > s1:10 > s2:20 To acheive this python script as follows infile=open("file1.txt",'r') out=open("file2.csv",'w') for line in infile: line = … | |
Hi, I have written a program that searches through a text file and in the end I want it to give me some probabilities. In my program I'm searching (for each line) for certain characters and if that character exists then extract the probability. The thing is that sometimes this … | |
I'm confused on how i can change or "toggle" the text of a button from say "D" to "A" when clicked, and then back to "D" if clicked again. So far I have this: [ICODE]from Tkinter import * from tkFileDialog import * class Game(Frame): def __init__(self,root): Frame.__init__(self,root) self.grid() self.buttons() def … | |
Hi guys I'm trying to place a user input into a database(mysql) [CODE]newplayer=raw_input('Please enter a new player name: ")[/CODE] the sql commands to insert data is [CODE]sql="""INSERT INTO PLAYERS(NAME) VALUES('newplayer')"""[/CODE] When i check the database it shows newplayer instead of what the user has entered. any ideas of how i … | |
Hi All, I want to create a pattern like this using python.. [CODE]Aa0Aa1Aa2Aa3Aa4Aa5......Ab0Ab1Ab2.........and so on.[/CODE] Thanks... | |
[code=python]import random secret = random.randint(1,99) guess = 0 tries = 0 print "AHOUY! I'm the Dread Pirate Roberts, and I have a secret!" print "It is a number from 1 to 99. I'll give you 6 tries. " while guess != secret and tries < 6: guess = input("What's yer … | |
I'm trying to write code to count the number of times a whole number can be divided by 2 before reaching 1. When I run my code it prompts me to enter a number as you'll see in my code below, but once I do so, nothing happens, just a … | |
I recently received an assignment in class and I need help really bad. The idea behind this assignment is to create a Network Backup Routine that that has a selection menu (New Backup Item, Remove Backup Item, Exit), I have been trying to create this program but with a sub … | |
I use the following code to read a CSV file with 6 columns. The headers are assigned correctly (i.e. print headers works) but when I try to read the rest of the rows as variables under those headers. The first column is 'time' and it is read correctly. But when … | |
I am trying to write a program that 1. Lets the user write new students and there overall grade to the file, 2. Opens the file to view course info(student and their grade) 3. Shows course stats(mean and range for the class). Here is what I have so far, can … | |
These are the original instructions: "Design and write a python program that emulates a Magic Eight Ball. Your program should continually prompt the user to enter a question and then display the answer as long as the user wishes to continue. Store eight Magic Eight Ball answers in an array. … | |
Hi, I'm trying to create a new file. In this file I want to add some results I have received from my code. Unfortunately I get a error message saying I can't combine str with list. So then I tried to make a string out of the list and ended … |
The End.