Skip to content

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 …

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 probl…