15,185 Topics
| |
[CODE] # PURPOSE: to calculate the sum of the first (n) counting numbers # # INPUT(S): the number (n) which will be the last number added to the sum # # OUTPUT(S): the sum of the first (n) counting numbers # # EXAMPLES: input: 4 ; output: 10 # input: … | |
I new to Python and I'm trying to make this script work, I made this in php, but I'd like to know how to do it in python... I'm trying to encode a file with base64 and then decode and write the binary data to a file. [CODE=Python]import base64 binaryfile … | |
Hi, all. Just been asked to help design a motion rig for a flight sim for a charitable museum in the UK. I have built robotic and control systems for a few years now mainly with PLC's some python and PICs. they are running Microsoft FS2004, and there is a … | |
Hi, I am new to python but I want to use it over perl because I think it is a better overall approach to programming. This is a bioinformatics problem. I have four identically formatted tab delimeted files that have genomic variation data. Each line looks like this. chr1 11828655 … | |
Hi, I have a dictionary storing many things... I would like to delete entries which have key of len < 3. But after I do the del statement, there are still lots of entries with len < 3, what happens? [CODE]for w in fdict.keys()[:]: if w.strip() in banset or len(w.strip()) … | |
How to start a new thread?Sorry am a new bee here. | |
Please help I'm having trouble getting my program to return any answer other than "You Lose!". Where is my mistake? Thanks in advance for any help. [code] print "Let's Play Rock, Paper, Scissors!!" print "Rock beats scissors, paper beats rock, and scissors beats rock and paper! Have fun!" import random … | |
hi guys can anyone explain to me this code. i dont really get this. thanks a lot. def readFile(name = ""): try: assert (name != "") , "The file name is not given!!" except AssertionError: print "file name is not given" else: try: f = open(name, 'r') except: print 'File … | |
How to fill array with any no like using zeros and ones. i'm new to python and i can't find the answer.... | |
Write a python function to convert a numeric input argument to a string output based on the following rules: >=10: A, 9:B, 8:C, 7:D, 6:E, <=5: F I came up with this, but it does not work at all table = {'A': 10, 'B': 9, 'C': 8, 'D': 7, 'E': … | |
hello there Iam using python 2.5.4 pyserial 2.4 pywin32-214 on windows 7 i hav a small test script written to query a serial device (arduino) and get back reply appropriately ////file: test.py import serial print 'hi' ser=serial.Serial(port='\\.\COM2', baudrate=9600) ser.close() ser.open() ser.write('1') ser.readline() ser.readline() ser.close() the device waits for '1' through … | |
Write a Python program that creates a dictionary of son-father pairs-you can make the pairs with fictional names for fun. Your program should populate this dictionary with the son-father pairs you made up. Your program should present the user a menu with two options. The following is an example: Father … | |
test = 4 #start of def def change(): test = 5 #end change() print test Why doesn't it print 5? Can anyone explain this to me? Btw, test = 5 is indented, the forum won't let me indent for some reason | |
Hi everyone I was wondering if I could get some help on environment variables. I am executing a cgi file from a C file with execv(). The cgi is able to generate the html template correctly. However I am unable to grab the "REQUEST_METHOD" since it always returns NULL. Can … | |
i need to create a program that translates an english phrase to a spanish phrase. i have a text file with english words and their spanish meaning. i am unsure how to start this as i am quite new to phyton. ignore the grammar, i want to translate the phrase … | |
here I have code in python and now I want to transfer it in Java. import logging import urllib import re from waveapi import events from waveapi import model from waveapi import robot from waveapi import document from django.utils import simplejson from google.appengine.api import urlfetch def OnDocChanged(properties, context): #Get Contents … | |
I would like to find and replace a string in a file. I know how to do this, but I can only do it for all instances. Is there a way to do it for just the first instance of the string in the file? import fileinput for line in … | |
[code] Traceback (most recent call last): File "C:/Python31/sample.py", line 10, in <module> calendar.prcal(year) AttributeError: 'module' object has no attribute 'prcal' [/code] Hello, I just started learning Python with this fantastic site. Unfortunatly I get this when i try to execute the following code [code] import calendar print( "Show a given … | |
hello, I have faced a problem that is almost as same as the problem below: ((((If I try to define a timer in an ogl.BitmapShape, like this: class T6963_device (ogl.BitmapShape): def __init__(self): ogl.BitmapShapeinit__ (self) self.t1 = wx.Timer (self) I get this error Traceback (most recent call last): File "D:\data_to_test\smtest2.py", line … | |
Hi everybody, I'm trying to install python 3 from source in my new Mandriva 2010. I have read a lot of posts in this website, but none of the instructions has worked for me. The code compiles and all, but it doesn't install tkinter. I know that tcl/tk are installed … | |
Hello, i would like to make program in python which reads the lines from an input file, which looks like this: Bob 10 20 30 John 15 15 Kate 20 and the program sums the numbers for each person and writes into an output file which should look like this: … | |
Hello friends, I have created simple rss reader class, but the class contains many loops and didn't work correctly and if anyone wants to help me with code, example, tutorial etc... I would be very grateful. The code of the class you can see on the following link: [url]http://pastebin.com/F7zQdhAW[/url] Thanks... | |
Hi I need some help with sizers. I just can not get my head around it and i cant find much on the net about what i am trying to achieve. I am not even sure if i need a grid sizer or two box sizers. This is what i … | |
Dear all, My window layout looks like this.. [img]http://i41.tinypic.com/hu27ax.jpg[/img] First, the dialog box that consists of listbox would appear to ask for user input. After the user input has been given, It will display in the next windows.. I have been trying to intergate the two coding together. However I … | |
I'm using python for a project and was curious if anyone knew whether it was possible to open up jpg files in a GraphWin window. Also, the image software I'm using with it is PIL, if that helps. | |
I'm new to here.so i posted it on the code thread pls go through it and help me [url]http://www.daniweb.com/code/snippet271890.html[/url] | |
[code]#Blast workbench using biopython from Bio.Blast import NCBIWWW ##result_handle = NCBIWWW.qblast("blastn", "nr", "8332116") fasta_string = "AATTCAGTGGCAAAAAAAAAACTCAAATTTTAGGGAAGGCCCTAATATTATCAAATAATTAGAGGGGGGG" result_handle = NCBIWWW.qblast("blastn", "nt", fasta_string) save_file = open("my_blast.xml", "w") save_file.write(result_handle.read()) save_file.close() result_handle.close() result_handle = open("my_blast.xml") from Bio.Blast import NCBIXML for record in NCBIXML.parse(open("my_blast.xml")) : #We want to ignore any queries with no search results: … | |
Is python web programming anything like php? Is there simple examples like submitting a form to perform a calculator functions etc? | |
I want to remove all the 1's from the sublists so l becomes [[2], [2], [2]] but have trouble keeping track of indices. Can someone help out? [CODE]l = [[1, 2, 1],[1, 1, 2],[2, 1, 1]] i = 0 for element in l: while i < len(element): if element[i] == … | |
Hello. I need some help. I have a function [icode]my_function(a, b, c, d)[/icode] which takes string parameters and output them in different combinations. It works well in IDLE, but I would like to output the result into a file. Such code [code=python]file = open("out_file.txt", 'w') file.write(my_function(a, b, c, d)) [/code] … |
The End.