my L1 array contains numbers like 0.029999999999999999 which i want to print off as 0.03
my code works, but gives an error at the end because the last count is out of ...
Say I have a function func(i) that creates an object for an integer i, and N is some nonnegative integer. Then what's the fastest way to create a list (not a ...
I'm building a range between two numbers (floats) and I'd like this range to be of an exact fixed length (no more, no less).
arange work with steps, ...
b=a or 'sss'
I want to get a default value when the list index is out of range (here:
How can I do this?
Below I have the following code that is supposed to get the CPU temperature.
w = wmi.WMI()
When I run it I get the following warning however:
Traceback (most recent call ...
I tagged this question with
poisson as I am not sure if it will be helpful in this case.
I need to create a distribution (probably formatted as an image in the ...
def findfreq(nltktext, atitem)
fdistscan = FreqDist(nltktext)
distlist = fdistscan.keys()
which relies on FreqDist from the NLTK package, and does not ...
From a list
mylist = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] how can I get a new list of lists composed of the first two elements of each ...
imagine that i have a list like
10 50 90
70 80 40
88 90 55
I sum an item with the others around it(so the sum of ...
I have problem with the netaddr package - version 0.7.5. This code works as expected and prints out the list of ip addresses in the range:
from netaddr import IPNetwork
ipnetwork = '192.168.0.0/24'
how is this possible, I have a list called "temp". This is what I have in my python interpreter.
In : len(temp)
In : temp
and I get an IndexError: list index ...
Hey, I am trying to build a set of ranges in python like so:
(0.1, 0.2, 0.7)
I want to build
[(0, 0.1), (0.1, 0.3), (0.3, 1)]
While this could be achieved easily ...
from xlwt import Workbook
wb = Workbook()
for file_name in glob.glob("foo*.xls"):
wb_orig = xlrd.open_workbook(file_name)
for ws_orig in wb_orig.sheets():
I know this is wrong thing to do, but I am using python 3 but studying it with python 2 book.
but I know it won't show the output ...
def remove_section(alist, start, end):
Return a copy of alist removing the section from start to end inclusive
>>> inlist = [8,7,6,5,4,3,2,1]
I have written a program that makes sure each cookie has more than 5 chips before moving on.
However, the line
if cookie[i] > 5: seems to be problematic, as it produces ...
I am studying the Learn Python The Hard Way PDF. On page 82 i come across this question.
- Could you have avoided that for-loop entirely on line 23 and just ...
This first lines work, and i get V(i) =V+QIN(i)-QOUT(i), but when i try to do
T(i) = (T + C(i) + TIN(i)*QIN(i)) /((C(i)+QIN(i)), how can I loop trought each C ...
What is a pythonic way of making list of arbitrary length containing evenly spaced numbers (not just whole integers) between given bounds? For instance:
my_func(0,5,10) # ( lower_bound , upper_bound , length ...
here is a list lst = [5, 3, 5, 1, 4, 7]
I want to get it ordered from the second element 3 to the end.
I thought I can do it by: ...
from os import path
input = open('/home/XXXXXX/ERR001268_1', 'r').read().split('\n')
at = 1
for lines in range(0, len(input)):
line1 = input[lines]
line4 = input[lines+3]
num1 = ...
I am new to Python and am getting the list index error, when I shouldn't.
I have the following variable:
date_array = ['2001','15','1']
I can access the first index. I can only access ...
I have the following code:
def steps(low, hi, n):
rn = range(n)
newrn = rn
print rn #print 1
for x in rn[:]:
newrn[x] = float(x)/n
diff = ...
Hey guys, This probly a really easy fix. I know this exception occurs when you try and access an index which does not exist, but this code worked fine then just started giving this error and i cant figure out why... cur.execute('select first, last from users where email = ?', [email]) userlist =  for user in cur.fetchall(): userlist.append( (user + ...
Re: getting ranges between lists? by gundliwe Fri Oct 28, 2011 10:20 am I get the error Traceback (most recent call last): File "Blocks.py", line 25, in Exon = set(blockrange) TypeError: unhashable type: 'list' Code: Select all #! /usr/bin/env python # Open the two files import sys import fileinput # Open the two files f1 = open(sys.argv, "r") f2_recs ...
List index out of Range HELP! by GeorgeM Thu Feb 17, 2011 4:40 am I'm a begginer and literally know none of the Python mumbojumbo. So basically I'm asking for someone to simply explain it is simple english or fixe it for me You'll see the problem if you run the program...thanks for your help!!! Here's my code: # gui.py ...
Code: Select all def coordinate_gen(width,length): coordinates= c_count=0 w_count=0 l_count=1 letters=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] width_list= length_list= for i in range(length): ...
Hi I have the following 2 lists l1 = [12, 34, 55... etc] l2 = [14, 56, 41...etc] they are the same length, but i want to know how to get the ranges of the corresponding numbers in each list and put that into a new list. So basically i want the range of 12 and 14, 34 and 56, so ...
def normList(L, normalizeToUp=1.4, normalizeToDown=-2.3): vMax = float(max(L)) vMin = float(min(L)) r = vMax-vMin nr = float(normalizeToUp - normalizeToDown) lNorm = [ normalizeToDown + (x/r)*nr for x in L] return lNorm
column_height = 10 candidate =  for i in xrange(0, column_height - 2): for j in matrix[i]: num = 1 for k in xrange(0, 3): num *= matrix[i+k][j] ...
Hello. How do I include a list of numbers into a range function? For example, if I have a list: list1 = [1,2,3] how do I use the range function so that it will use the numbers from the list? I tried this : list1 = [1,2,3] >>>for i in range(list1): >>>print i and some variations of it but it doesn't ...
Here's the code: Code: Select all class Employee: def __init__(self, name, age, gender, salary): self.name = name self.age = age self.gender = gender self.salary = salary def ...
data = ['0','one','two','three','four','five','six','7','8','9','10','1','3','11','12','14'] for i in data: if i == '0': print i Traceback (most recent call last): File "C:\scripts\Python-1.py", line 15, in print i IndexError: string index out of range