I’m trying to loop through a table that contains covid-19 data. My table has 4 columns: month, day, location, and cases. The values of each column in the table is stored in its own list, so each list has the same length. (Ie. there is a month list, day list, location list, and cases list). There are 12 months, with
Tag: nested-loops
Creating a table with nested loops in python
I’m learning abort nested loops and I’ve gotten an assignment to create a function that takes two integer inputs. Then it should create something like in this image. Only problem is that when I use an odd number for columns it doesnt work. It has to be an “advanced nested loop” for the assignment to be approved. createTable(1, 2) Answer
Why is python printing weird results while using the nested loop here?
I was given an array of strings and I want to split each of the individual strings into separate characters and store them in a separate 2-D array. I wrote the following code:- But doing this gives weird values in my two-dimensional array, mat. Each of the row of the 2D array mat gets printed as [‘1′,’2′,’3′,’4’] but this should
How to iterate through a nested for loop in pandas dataframe?
I am attempting to iterate through a Hacker News dataset and was trying to create 3 categories (i.e types of posts) found on the HN forum viz, ask_posts, show_posts and other_posts. In short, I am trying to find out the average number of comments per posts per category(described below). The results respectively are; 395976587 250362315 and 43328.21829521829 24646.81187241583 These seem
Is there a way to print all substrings of a string in O(n) time?
I have an input abcde. I’m trying to output something like this: I can’t make a code which is without nested loops. My question is what is the solution of this problem with O(n) time complexity? My code is given below: Answer Lets do this without a nested loop! This a game with random library, but the execution time is