Skip to content

Tag: python

hexToBinary dictionary

So I am working on this problem: Recall from the Number Systems unit the method for converting hexadecimal numbers to binary by converting each hex digit to its equivalent four binary digits. Write a Python function named hexToBinary with parameters (number, table) that uses this algorithm to convert a hexade…

Simulate autofit column in xslxwriter

I would like to simulate the Excel autofit function in Python’s xlsxwriter. According to this url, it is not directly supported: http://xlsxwriter.readthedocs.io/worksheet.html However, it should be quite straightforward to loop through each cell on the sheet and determine the maximum size for the colum…

Advertising on a tkinter program

My question is : is it possible to put ads on a tkinter program , something like google ads or something , because I made a program which a lot of people started using and I am not getting any benefits from it , is there a way ? Answer There is nothing built-in to tkinter, nor available as a

Change multiple items in a list at one time in Python

Can I change multiple items in a list at one time in Python? Question1: For example,my list is I want to the third and fifth item become 99.I know I can do it by However, is there any easier way to do this? Question2:in the situation,my target value is[99,98], my index is [2,4],so my result would be [0,0,99,0…

Accessing elements of multi-dimensional list, given a list of indexes

I have a multidimensional list F, holding elements of some type. So, if for example the rank is 4, then the elements of F can be accessed by something like F[a][b][c][d]. Given a list L=[a,b,c,d], I would like to access F[a][b][c][d]. My problem is that my rank is going to be changing, so I cannot just have F…

Sum slices of consecutive values in a NumPy array

Let’s say I have a numpy array a containing 10 values. Just an example situation here, although I would like to repeat the same for an array with length 100. I would like to sum the first 5 values followed by the second 5 values and so on and store them in a new empty list say b. So b