15,181 Topics
| |
I want to create a string like this: (just theoretically:-)) [CODE]import random list1 = ["1", "2", "3"] string1 = random.choice(list1) string2 = "Random Number is" + string1 [/CODE] but I want string2 to show up formatted like this: Random Number is [INDENT] 2[/INDENT] But, for the life of me I … | |
Hi there, Trying to write a small script in python. What it will basically do is this; 1- A SSH user initiates the python script (from SSH remotely) 2- The script gets the connected users IP (the user is connected through SSH) 3- The connected IP is sent back to … | |
binding_locations(strA, strB) My specifications The first parameter represents a strand of DNA. The second parameter is one strand from a recognition sequence. Return a list of all the indices where the recognition sequence appears in the DNA strand. (These are the restriction sites.) ------------------------------------------------------- For example, if the DNA palindrome … | |
This is a very basic question, but I'm very new to python. I want to read data in a file. The data is between two delimiters. I'm not exactly sure how I can extract the data and skip the delimiters. Any help would be great. | |
Ok my program looks like this: [CODE]U = set([0,1,2,3,4,5,6,7,8,9]) A = set([2,4,5]) B = set([5,8]) C = set([5]) def main(): print('This is a program to give complement to given elements') x = input('Enter elements bla bla: ') y = U.difference(x) print('The complement of given elements are:', y) main()[/CODE] As you … | |
Hello Everyone I am new to this forum and new to learning Python. I was looking for a good book to help teach it to myself and on a recommendation purchased the book [I]Python Programming In Context[/I] by Bradley Miller and David Ranum. This is a good book in terms … | |
I ran into a something I did not expect when making a small program. I'm not including the whole program, just exemplifying the stick in the wheel, as it's part of a homework assignment. I'd just like some clarification on why the last "x = 1" is ignored. [CODE] x … | |
Hi to all, I am new to python environment,i got the knowledge about REST and python.. But i didn't know how to implement it... I requesting you to give me some suggestion... | |
I have a wx.ListCtr: [CODE] self.resultList = wx.ListCtrl(self.rightPanel, -1, style=wx.LC_REPORT | wx.EXPAND) f = self.GetFont() dc = wx.WindowDC(self) dc.SetFont(f) i = 0 for items in (SEARCHPARAMS): self.resultList.InsertColumn(i,items) width, height = dc.GetTextExtent(items) self.resultList.SetColumnWidth(i, width) i +=1[/CODE] I'd like to populate the ListCtrl from a dictionaries contained within an object list. I … | |
Hi All, I need to parse the out from following output: I need to get the adapter detail after the heading "System Adapter Configuration:" This adapter detail is in 2nd cloumn like ACPI_IA64_P, ACPI_IA64_B, XBUS and PCI. I have marked the desired output in [COLOR="Red"]RED[/COLOR] color. Please help me in … | |
I want to allow certain characters to a string For example I want strA to contain either 'A' or 'B' or 'C' or 'D' How do I do that, help would be greatly appreciated. Thanks strA = 'A' or 'B' or 'C' or 'D' | |
I'm having a tough time figuring this out. we need to fill in the blanks [CODE]import ____________ def wordCount(): lineCnt = 0 wordCnt = 0 charCnt = 0 list = [] ______________ = _______________("Enter the filename : ") file = ________(filename, __________) for _________ in file: ____________ += 1 list … | |
[code] def a(classname,highdamageweaponname,lowdamageweaponname,ldmgname,hdmgname,yourhealth,enemyhealth,ldmgspellname,hdmgspellname): import os import random os.system("clear") monsters = ['cyclopse', 'duck', 'dragon', 'wizard', 'magician'] randommonster = random.choice(monsters) print "Class: %s" % classname print "1) %s (More damage, but less armor)" % highdamageweaponname print "2) %s (Less damage, but more armor)" % lowdamageweaponname a = int(raw_input("You are battling a %s … | |
hey guys.. I wana implement a stop watch in python... The timer turns on when my program starts and continuesly shows the time spent until the end of the program.. Can someone please help me with this..?? | |
| I am trying to add a path to sys.path fix an error importing numpy. If I do: [CODE]import sys sys.path.append('/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages') print sys.path[/CODE] then path that I just added shows up and import numpy works. However, if I restart IDLE and try to import numpy again, I get an error. How … |
My code is [CODE]def is_base_pair(str1, str2): if lens(str1) == 1 and lens(str2) == 1: if (str1 == "A" and str2 == "T") or (str1 == "G" and str2 == "C") or (str1 == "T" and str2 == "A") or (str1 == "C" and str2 == "G"): return True else: return … | |
I have a dicationary [code=python] x={'symbol':LTV,'user':derek,'where':home,'time':night} [/code] Obviously when u print it the dictionary doesnt keep the order you put them in. how do i have a dictionary that has it the way i input them? I looked online, but not sure to you cmp, lambda, etc? Thanks for the … | |
Return the longest odd-length palindrome centered at the int index in the str. Assume that the index is valid, that the length of the str is at least one, and that there are only lowercase letters: no punctuation, spaces, or uppercase letters. I just want to know what this question … | |
I am reading in files containing 238 x 1 feature vectors. Attempting to grab the first 2 numbers in each file to create a 2d plot using numpy. I've got a decent start, just am stuck on how to fill the np array that I want to plot. [CODE] import … | |
[CODE]def get_even_palindrome_at(user_input, index): user_input = user_input.lower() user_input = remove_non_words(user_input) start_index, end_index = index, index while start_index >= 0 and end_index < len(user_input): if user_input[start_index] == user_input[end_index]: start_index -= 1 end_index += 1 else: break result = "" count_index = start_index while count_index < end_index: result += user_input[count_index] count_index = count_index … | |
Hey there, I've never actually used a forum to ask for help on any sort of project before, but I'm a little stuck.. okay, a lot. =D It's probably something really stupid and minuscule, though. Anyway, heres the project.. I hope it's not too confusing: Write a program that asks … | |
Printing a convenient [url=http://en.wikipedia.org/wiki/ANSI_escape_sequence]ansi escape sequence[/url] clears the terminal (if you're running python from a terminal). Similar techniques could be used to print in colors. | |
Evening there. [B]I need to return an (x,y) tuple of an object, This x,y will be used to help 1 object calculate where the other object is and move towards it.[/B] My problem is that both the objects need to know the others' x,y. (i'm unsure how to get the … | |
im taking a class in python but i just cant keep up with the curriculum. Some things confuse me so i was wondering if anyone have any websites or anything that can help me get through python or at least help me understand it easier. the book im using right … | |
hi, Im calling Oracle 10g stored proc from python 2.6. 1. How do I pass String VArray (list in python) to stored proc ? 2. How do I return cursor from Oracle stored proc ? 3. How do I return list of strings from Oracle stored proc ? My Oracle … | |
kind of a basic question but i cant seem to figure it out. well i have a list and i split it up using the split function but now im confusing how i can use one string and divide it to another. i tried turning it into a int or … | |
[CODE]reply=float(raw_input("Enter your choice: ")) if reply!=1 or reply!=2: print "Not a Valid Choice" [/CODE] i cant use while loops other wise i prob wouldve done so. Basically im trying to get the user input to only allow the numbers 1 or 2. anything else should give a not a valid … | |
Hey, everyone. I know how to strip certain characters from a string using for loop. Can you give an example of how that can be done with the use of while loop? | |
So i have a h/w assignment due tomorrow, and i have tried to work on it, but as usual, python frustrates me. Here is the assignment: [url]http://www.cs.gonzaga.edu/depalma/courses/cpsc121/assignPython/asgn5.pdf[/url] and for part two, here is the link for example26 it says to use: [url]http://www.cs.gonzaga.edu/depalma/courses/cpsc121/examplesPython/example26.py[/url] So i tried working out the first part … | |
I need help with my Palindrome code For some reason, I cannot seem to convert the text into lower case letters and I cannot seem to ignore spaces and commas and periods and so on. Here is my code [CODE]def is_palindrome(user_input): i = 0 result = True while i <= … |
The End.