typeerror

Error when trying to create a list of files

Error when trying to create a list of files Question: I have a folder that contains 20 csv files. Each file has about 10 columns and thousands of rows. The csv files look something like the following: gene p-value xyz acan 0.05 123 mmp2 0.02 456 mmp9 0.07 789 nnos 0.09 123 gfap 0.01 456 …

Total answers: 1

Kwarg argument initialized as "NoneType"

Kwarg argument initialized as "NoneType" Question: I have an object class that takes sidewalk data and parses it for a transportation model. At one point in the model, it uses a function of the sidewalk width and the pavement conditions to generate a score. This is relevant because the width and pavement condition score are …

Total answers: 1

Getting error when I run my program. What do I need to change?

Getting error when I run my program. What do I need to change? Question: import random, string characters = string.ascii_letters + string.digits + string.punctuation def generate_random_password(): length = int(input("How many characters in password? ")) number_of_passwords = int(input("How many passwords would you like? ")) character_count = characters if character_count > str(length): print("To long, try again") return …

Total answers: 2

Python TypeError: 'tuple' object is not callable when using list comprehension inside for loop

Python TypeError: 'tuple' object is not callable when using list comprehension inside for loop Question: I’m trying to generate a list of strings using a list comprehension, where the string is formatted using f-strings: features = [("month", (1, 12)), ("day_of_year", (1, 365))] for feature, range in features: cols= [f"transformed_{feature}_period_{i:02d}" for i in range(12)] If I …

Total answers: 2

Decorator causing my function to not accept positional argument?

Decorator causing my function to not accept positional argument? Question: I am learning how to use decorators. Inspired by tqdm library (progress bars), I have cobbled together a decorator, heavily inspired by this code. The goal is to use multithreading to have a progress indicator blink/spin/count in stdout while a long-running function that does not …

Total answers: 2

i have Error codes when running my python program

i have Error codes when running my python program Question: I have this python script that calculates the factorial of number. import math def calculate_factorial(n): if n < 0: return 0 elif n == 0: return 1 else: return n * calculate_factorial(n – 1) def main(): n = input("Enter a number: ") factorial = calculate_factorial(n) …

Total answers: 1

not all arguments converted during string formatting (while passing arguments to function)

not all arguments converted during string formatting (while passing arguments to function) Question: I am getting error "not all arguments converted during string formatting" while running this code please explain how to fix this and what is this error def multiples(l,n): count=0 for i in l: if(i%n==0): count+=1 return count m=input("no of elements: ") l=[] …

Total answers: 1

Python function to count divisible numbers in a list?

Python function to count divisible numbers in a list? Question: I need to write a python function that takes a list as the input and calculates the number of numbers divisible by some other number, n. This is the code I have so far: enter image description here Could someone advice me on what approach …

Total answers: 2