Questions tagged [operation]

734 questions
-1
votes
1 answer

analysis of algorithm

Assume a machine has a throughput of 70 ops/s. Say we have an algorithm with time complexity T(n) = 2n^2 + 120 Determine how many hours will it take the machine to execute said algorithm for an input of size n = 8. Is this correct? T(n) = 2n^2 +…
toky
  • 119
  • 1
  • 5
  • 15
-2
votes
1 answer

Comparison Operation of List Data Structure on Python

Assuming that I have a List data strecture: list. And I see one code: list[:,0]>5 I don't know what it means? But I know what list[:,0] means. I google it and read many in python.org but I can't acquire appropriate answer.
Kk Lee
  • 1
  • 1
-2
votes
2 answers

Python Sum with 3 nested list and empty list Explanation

l = [ [[1,2,3], [2,3,4]] ] sum(l,[]) Output ist [[1, 2, 3], [2, 3, 4]] I don't know why it works like this. I tired the two below [].__add__(l) # First Try [] + l # Secodn Try In both cases, the output was as follows. [[[1, 2, 3], [2, 3,…
조해피
  • 7
  • 2
-2
votes
4 answers

I can't figure out what is wrong with this function?

This is what it should return Returns True if all items are truthy. Examples: >>> all_true([1, True, 'oregonstate']) True >>> all_true([0, 1, 2]) False """ This is what I have written def all_true(items): for i in items: if i == True: …
Jack
  • 1
-2
votes
1 answer

using ternary operation instead of if statement

I want to do this code you have seen using ternary operation instead of if conditional blocks. Generally, is the use of the ternary operator always a good choice? In some places they say it is more readable and more flexible code to use the ternary…
-2
votes
1 answer

UnboundLocalError: local variable 'infile' referenced before assignment

I am having difficulties tracing an error in my code. Getting a "UnboundLocalError: local variable 'infile' referenced before assignment" error all the time I enter a file name that do not exist. def spam(): fname = input('Enter the file name:…
Tomas
  • 1
-2
votes
1 answer

Scipy and pulp which will be better if using cplex solver

Which among python libraries like pulp and Scipy , has the capability to work with Cplex solver .If we have huge constraints and datasets for optimisation in supply chain .
-2
votes
1 answer

Problem doing multiplication operation in a select between a float and an integer in sqlite

Problem Hi, I have this problem when I do this operation between a float and an integer number. select codventa, cantidad, precio, cantidad * precio from ventas v, detallesventas dv where v.codventa = 23 and dv.codventa = v.codventa Instead of…
diego
  • 3
  • 2
-2
votes
6 answers

Set Intersection with None

I am having trouble with set operation intersection. Assume I have a list A = [0,1,2,3], and an integer B = 0. When I check if B in A:, I am getting of course True. But when A and B are as default equal to None, than I can't do the intersection…
oakca
  • 1,408
  • 1
  • 18
  • 40
-2
votes
2 answers

How to perform math operation on numbers in string of python

How we can perform mathematical operation on string in python. Consider below example with open('/home/akashk/projects/math.txt') as f: content = f.readlines() content = [x.strip() for x in content] for x in content: print(x) …
Akash Kinwad
  • 704
  • 2
  • 7
  • 22
-2
votes
2 answers

Python multiplication operation returns false repeating decimal

I was doing my program for a school project when I encountered a problem which I'm unable to understand after trying many different methods to resolve it. I have a function that does a simple mathematical operation like this: def pikkus(kogupikkus,…
harlu
  • 9
  • 3
-2
votes
5 answers

Use aggregate function with arithmetic operation

I have a table with two columns Here I need to find a SQL according to the following function, Z = accelx-AVG(accelx) for every rows.
-2
votes
1 answer

error: invalid operands to binary expression 'float'

Hello and sorry if this question has been asked before, but I'm working on the Josephus problem and this is the code that I´ve written. #include #include #include int main(void) { printf("Number of people: "); …
-2
votes
1 answer

Java operating long numbers

Have been doing a mathematic example in java which would find all numbers between number1 and number2(including number1 and number2) that divide numbers 2 ,3 or 5. I don't need all those numbers, just how many numbers there are. So for example if…