Skip to content
Advertisement

Tag: logic

How to extract value from tuple of tuples

I have list of this sort. It is the order list of a person: How do I extract the string and the float value separately? I need to calculate the total order cost based on the given fruit prices: This is what I have tried: This yields wrong answer. What am I doing wrong? How can I fix this? Thanks!

Python script to extract data from csv file

sharing the sample file screenshots, script I developed and other details below. In the countries_source.csv file, I have a list of countries and I need a subset of its data created in mycountries.csv file until I hit the value “Asia” in the first column. Using the below script, I was able to get the data till the 14th row –

How to optimise function logic to avoid duplication – python

I have some code below, for a given name that matches pattern with 2 lower case letters (such as ‘aa’), the valid name can be V-aa or X-aa My question is: can I do something like: Answer From your description, I assume that verify_helper() is computationally expensive regardless of names being valid. Now you want to optimize the code, by

Iterating through records with SQL INSERT activated stops after first set of INSERTS, but using PRINT to test goes through EVERY record (as desired)

Python 3.10.2 with sqlite3 on Windows 10. Relatively new to Python, but I was quite experienced with Perl around 1997-2005. Banged my head against this for three days. Attacked from lots of angles. No success. I’m asking for guidance, because I don’t see myself progressing on my own at this point without help flipping on the light-switch. My overall application

How to find maximum group size dynamically

I want to find the maximum group size g_new if I want to partition a list of ‘n’ values. We can have any number of groups. I have: n values and maximum group size possible g_max. e.g. n = 110 and g_max = 25. We cannot form groups of size: [28,28,27,27] as no group should be more than 25! Here,

Python: Maximum Subarray Sum

I’ve just tried to start learning Python today, so I am not knowledgeable when it comes to it’s functions. However, I found the maximum subarray problem, and wanted to try and solve it with the few, simple logical commands I have at my disposal. I have gotten stuck, and am almost certain the problem is in my logic and not

Advertisement