Skip to content
Advertisement

Tag: loops

Python (Sum of expense, income, and profit)

In Python I have a list of entries. I need to get the sum of expenses, the sum of income, and the profit. I’ve been able to get the expenses and income. Looking to break out the profit. I know I’m missing something simple but can’t figure it out. Answer Looks like you just want to calculate the profit/expenses/income for

Python iterate folder of csv and convert do json

I am amateur at python but I have a task of converting folder of csv to json files. I have this script working with specified CSV file but I have no idea how to make the script iterate thrue folder of csv and convert all of those csv to json. The original script: someone will give me a hint? Answer

for loop with zip in python

I want to use zip to iterate to existing Lists. I did that with the code below. Currently the output is just Name –> Name. How do I use the new creates list or if that’s not possible the other lists to print following sentence: “#NAME is #AGE years old, and they can be called at #NUMBER”. Is it possible

Iterating through a column and mapping values

Here is what I am trying to do. I want to substitute the values of this data frame. For example. Bernard to be substituted as 1, and then Drake as 2 and so on and so forth. How to iterate through the column to write a function that can do the following. Answer The function already exists – pd.factorize. It

Output variable names when summing a tuple

A list of variables with assigned values. I want to return all the possible combinations from each pair (every two of them). The print-out is the names of the pair, and sum of them. For example: I’ve tried below. The result comes out, but not the names of pairs: What’s the right way to do it? Answer If you use

How can I create a loop with my conditions

i am looking for help. We need to write a program that prints all numbers in the range of (n -20,n + 20). In addition, the program asks you beforehand to input a number. If that number is not even or multiple of 10, you need to take a guess again. Only if the number is even and multiple by

Advertisement