Class-XII Computer Science
Class-XII Computer Science
SCIENCE(083)
def sum(numbers):
total = 0
for x in numbers:
total += x
return total
print(sum((8, 2, 3, 0, 7)))
3. Write a Python function to multiply all the numbers in a list. (Sample List : (8, 2, 3, -1, 7)
Expected Output : -336)
def multiply(numbers):
total = 1
for x in numbers:
total *= x
return total
print(multiply((8, 2, 3, -1, 7)))
4. Write a Python function to check whether a number falls within a given
range.
def printValues():
l = list()
for i in range(1,21):
l.append(i**2)
print(l)
printValues()
Output:
6. Write a Python program that invokes a function after a specified period of time.
Sample Output: Square root after specific miliseconds: 4.0, 10.0, 158.42979517754858
Output:
Square root after specific miliseconds:
4.0
10.0