Thats how the list looks like incomes = [‘Kozlowski’, 52000, ‘Kasprzak’, 51000, ‘Kowalski’, 26000] I want to print the biggest income and the surname of the person with that income (index of the income – 1) Answer If your pattern is [“SURNAME_1”, INCOME_1,…
Tag: python
Select query is working but insert query is not in Python with Couchbase library
I’m trying to do some remote operations with Couchbase Python library. I have written a small code piece to test if it is working as intended. Select function works well. Query runs and there is no problem. But the other one, which I’m trying to use for inserting, doesn’t work. It gives a ti…
Linear regression plot on log scale in Python
I want to do linear regression to the data given by x and y. Everything seems to be fine when I use a linear plot, but when I want to plot it on a log scale the line does not look straight. I think I should divide the interval into finer grids rather than only six points. But I couldn’t
Divide matrix into submatrix python
The program must accept an integer matrix of size R*C and four integers X, Y, P, Q as the input. The program must divide the matrix into nine submatrices based on the following condition. The program must divide the matrix horizontally after the Xth row and Yth row. Then the program must divide the matrix ver…
How to convert Python Integer to Roman Numeral and vice-versa? [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 12 months ago. Improve this question I am trying to write a Python program that accepts integer as input and …
Items not being appended properly
I was working on the following code which will take input the scrap which has a few phrases as: Now I want the phrases in scrap which have used the words in prog_list to be appended to TRUE_PROG : I wrote a simple code having loops in it, but it produces an output that I didn’t expect: PROGRAM CODE: If
Usage of sorted with ord() and lambda in python
I was doing an exercise on Hackerrank, and in the discussion I stumbled upon a very nice one line solution to solve the following question: S is an alphanumeric string, and you have to sort it using the following rules: All sorted lowercase letters are ahead of uppercase letters. All sorted uppercase letters …
Python regular expression how to deal with multiple back slash
I’m dealing with text data and having problem erasing multiple back slashes. I found out that using .sub works quite well. So I coded as below to erase back slash+r n t f v However, the code above can’t deal with the string below. So coded as this: But it’s showing result like this.. I don’t know why this hap…
How to get wave module methods for reading a .wav audio but with a temporary file tempfile.SpooledTemporaryFile obtained from fastAPI post request?
I have a function that receives a .wav audio path directory and return its pcm_data in bytes, sample_rate as int and duration as float. Now I want that the audio file comes from a uploaded audio using POST request with FastAPI, so if I upload a .wav audio using the UploadFile class from fastapi, I get a tempf…
How to convert this text file into panda tables to make plots?
Here is an image of the text file: Answer Try using pd.read_csv and some parameters: Content of data.csv: