Finished and ran reorganize.sh
This commit is contained in:
BIN
Lab 1 - Group Work/lab1_files/autograde/.DS_Store
vendored
Normal file
BIN
Lab 1 - Group Work/lab1_files/autograde/.DS_Store
vendored
Normal file
Binary file not shown.
67
Lab 1 - Group Work/lab1_files/autograde/GRADING/APPEND.py
Normal file
67
Lab 1 - Group Work/lab1_files/autograde/GRADING/APPEND.py
Normal file
@@ -0,0 +1,67 @@
|
||||
|
||||
#############################################################################
|
||||
from typing import Callable
|
||||
def testHarness(fcn: Callable, arg: str, expected: str | list) -> int:
|
||||
''' function to help test an arbitrary function having one argument
|
||||
Parameters:
|
||||
fcn: the actual function being tested (pass without calling)
|
||||
arg: the argument being passed to the tested function
|
||||
expected: the expected result, either str or list in the context here
|
||||
Returns:
|
||||
None -- just prints
|
||||
'''
|
||||
result = fcn(arg) # call the student's function, passing the given argument
|
||||
|
||||
# see https://unicode-table.com/en/sets/check/
|
||||
# replace these as you see fit
|
||||
mark = "✓" if result == expected else "✗"
|
||||
print(f"Testing {fcn.__name__}({repr(arg)}):")
|
||||
print(f"\t {mark} result = {result}")
|
||||
print(f"\t expected = {expected}")
|
||||
|
||||
if result == expected:
|
||||
return 1 # correct +1
|
||||
return 0 # incorrect +0
|
||||
|
||||
###################
|
||||
def main_grading():
|
||||
count = 0
|
||||
tests = 0
|
||||
|
||||
arg = []; expected = 0; tests += 1
|
||||
count += testHarness(compute_sum, arg, expected)
|
||||
|
||||
arg = [0]; expected = 0; tests += 1
|
||||
count += testHarness(compute_sum, arg, expected)
|
||||
|
||||
arg = [1,2,3]; expected = 6; tests += 1
|
||||
count += testHarness(compute_sum, arg, expected)
|
||||
|
||||
arg = [-1,2,-3]; expected = -2; tests += 1
|
||||
count += testHarness(compute_sum, arg, expected)
|
||||
|
||||
|
||||
arg = []; expected = None; tests += 1
|
||||
count += testHarness(compute_product, arg, expected)
|
||||
|
||||
arg = [0]; expected = 0; tests += 1
|
||||
count += testHarness(compute_product, arg, expected)
|
||||
|
||||
arg = [1,2,3]; expected = 6; tests += 1
|
||||
count += testHarness(compute_product, arg, expected)
|
||||
|
||||
arg = [-1,2,-3]; expected = 6; tests += 1
|
||||
count += testHarness(compute_product, arg, expected)
|
||||
|
||||
arg = [-1,-2,-3]; expected = -6; tests += 1
|
||||
count += testHarness(compute_product, arg, expected)
|
||||
|
||||
arg = [-1,-2,-3,0]; expected = 0; tests += 1
|
||||
count += testHarness(compute_product, arg, expected)
|
||||
|
||||
print('-' * 30)
|
||||
print(f"Total tests passed: {count} / {tests}")
|
||||
print('-' * 30)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main_grading()
|
||||
@@ -0,0 +1,56 @@
|
||||
def compute_sum(list_: list[int]) -> int:
|
||||
''' function to compute the sum of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the integer sum of the list of integers
|
||||
'''
|
||||
sum_ = 0
|
||||
for i in list_:
|
||||
sum_ += i
|
||||
return sum_
|
||||
|
||||
print(compute_sum([0,0,0]))
|
||||
print(compute_sum([1,2,3,4,5]))
|
||||
print(compute_sum([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_sum([1,1,1,1,1,1,1]))
|
||||
print(compute_sum([1,2,3,4,5,4,3]))
|
||||
|
||||
def compute_product(list_: list[int]) -> int | None:
|
||||
''' function to compute the product of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the product sum of the list of integers; if the list is
|
||||
empty, we return None
|
||||
'''
|
||||
if len(list_) == 0: return None
|
||||
product = 1
|
||||
for i in list_:
|
||||
product *= i
|
||||
return product
|
||||
|
||||
print(compute_product([0,0,0]))
|
||||
print(compute_product([1,2,3,4,5]))
|
||||
print(compute_product([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_product([1,1,1,1,1,1,1]))
|
||||
print(compute_product([1,2,3,4,5,4,3]))
|
||||
|
||||
def main():
|
||||
print(compute_sum([0,0,0]))
|
||||
print(compute_sum([1,2,3,4,5]))
|
||||
print(compute_sum([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_sum([1,1,1,1,1,1,1]))
|
||||
print(compute_sum([1,2,3,4,5,4,3]))
|
||||
|
||||
print(compute_product([0,0,0]))
|
||||
print(compute_product([1,2,3,4,5]))
|
||||
print(compute_product([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_product([1,1,1,1,1,1,1]))
|
||||
print(compute_product([1,2,3,4,5,4,3]))
|
||||
|
||||
main()
|
||||
@@ -0,0 +1,43 @@
|
||||
def compute_sum(list_: list[int]) -> int:
|
||||
''' function to compute the sum of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the integer sum of the list of integers
|
||||
'''
|
||||
sum_ = 0
|
||||
for i in list_:
|
||||
sum_ += i
|
||||
return sum_
|
||||
|
||||
print(compute_sum([0]))
|
||||
|
||||
print(compute_sum([1,2]))
|
||||
|
||||
print(compute_sum([3,4,5,6,7]))
|
||||
|
||||
print(compute_sum([-3,4,5,6,7]))
|
||||
|
||||
def compute_product(list_: list[int]) -> int | None:
|
||||
''' function to compute the product of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the product sum of the list of integers; if the list is
|
||||
empty, we return None
|
||||
'''
|
||||
if len(list_) == 0: return None
|
||||
product = 1
|
||||
for i in list_:
|
||||
product *= i
|
||||
return product
|
||||
|
||||
print(compute_product([0]))
|
||||
|
||||
print(compute_product([1,2]))
|
||||
|
||||
print(compute_product([3,4,5,6,7]))
|
||||
|
||||
print(compute_product([-3,4,5,6,7]))
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
def compute_sum(list_: list[int]) -> int:
|
||||
''' function to compute the sum of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the integer sum of the list of integers
|
||||
'''
|
||||
sum_ = 0
|
||||
for i in list_:
|
||||
sum_ += i
|
||||
return sum_
|
||||
|
||||
print(compute_sum([0]))
|
||||
|
||||
print(compute_sum([1,2]))
|
||||
|
||||
print(compute_sum([3,4,5,6,7]))
|
||||
|
||||
print(compute_sum([-3,4,5,6,7]))
|
||||
|
||||
def compute_product(list_: list[int]) -> int | None:
|
||||
''' function to compute the product of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the product sum of the list of integers; if the list is
|
||||
empty, we return None
|
||||
'''
|
||||
if len(list_) == 0: return None
|
||||
product = 1
|
||||
for i in list_:
|
||||
product *= i
|
||||
return product
|
||||
|
||||
print(compute_product([0]))
|
||||
|
||||
print(compute_product([1,2]))
|
||||
|
||||
print(compute_product([3,4,5,6,7]))
|
||||
|
||||
print(compute_product([-3,4,5,6,7]))
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
def compute_sum(list_: list[int]) -> int:
|
||||
''' function to compute the sum of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the integer sum of the list of integers
|
||||
'''
|
||||
sum_ = 0
|
||||
for i in list_:
|
||||
sum_ += i
|
||||
return sum_
|
||||
|
||||
print(compute_sum([0]))
|
||||
|
||||
print(compute_sum([1,2]))
|
||||
|
||||
print(compute_sum([3,4,5,6,7]))
|
||||
|
||||
print(compute_sum([-3,4,5,6,7]))
|
||||
|
||||
def compute_product(list_: list[int]) -> int | None:
|
||||
''' function to compute the product of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the product sum of the list of integers; if the list is
|
||||
empty, we return None
|
||||
'''
|
||||
if len(list_) == 0: return None
|
||||
product = 1
|
||||
for i in list_:
|
||||
product *= i
|
||||
return product
|
||||
|
||||
print(compute_product([0]))
|
||||
|
||||
print(compute_product([1,2]))
|
||||
|
||||
print(compute_product([3,4,5,6,7]))
|
||||
|
||||
print(compute_product([-3,4,5,6,7]))
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
def compute_sum(list_: list[int]) -> int:
|
||||
''' function to compute the sum of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the integer sum of the list of integers
|
||||
'''
|
||||
sum_ = 0
|
||||
for i in list_:
|
||||
sum_ += i
|
||||
return sum_
|
||||
|
||||
print(compute_sum([0]))
|
||||
print(compute_sum([1,2,3]))
|
||||
print(compute_sum([-1,-2,-3]))
|
||||
|
||||
def compute_product(list_: list[int]) -> int | None:
|
||||
''' function to compute the product of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the product sum of the list of integers; if the list is
|
||||
empty, we return None
|
||||
'''
|
||||
if len(list_) == 0: return None
|
||||
product = 1
|
||||
for i in list_:
|
||||
product *= i
|
||||
return product
|
||||
|
||||
print(compute_product([0]))
|
||||
print(compute_product([1,2,3]))
|
||||
print(compute_product([-1,-2,-3]))
|
||||
|
||||
def main():
|
||||
value = compute_sum([0])
|
||||
print(value)
|
||||
value = compute_sum([1,2,3])
|
||||
print(value)
|
||||
value = compute_sum([-1,-2,-3])
|
||||
print(value)
|
||||
|
||||
main()
|
||||
@@ -0,0 +1,56 @@
|
||||
def compute_sum(list_: list[int]) -> int:
|
||||
''' function to compute the sum of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the integer sum of the list of integers
|
||||
'''
|
||||
sum_ = 0
|
||||
for i in list_:
|
||||
sum_ += i
|
||||
return sum_
|
||||
|
||||
print(compute_sum([0,0,0]))
|
||||
print(compute_sum([1,2,3,4,5]))
|
||||
print(compute_sum([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_sum([1,1,1,1,1,1,1]))
|
||||
print(compute_sum([1,2,3,4,5,4,3]))
|
||||
|
||||
def compute_product(list_: list[int]) -> int | None:
|
||||
''' function to compute the product of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the product sum of the list of integers; if the list is
|
||||
empty, we return None
|
||||
'''
|
||||
if len(list_) == 0: return None
|
||||
product = 1
|
||||
for i in list_:
|
||||
product *= i
|
||||
return product
|
||||
|
||||
print(compute_product([0,0,0]))
|
||||
print(compute_product([1,2,3,4,5]))
|
||||
print(compute_product([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_product([1,1,1,1,1,1,1]))
|
||||
print(compute_product([1,2,3,4,5,4,3]))
|
||||
|
||||
def main():
|
||||
print(compute_sum([0,0,0]))
|
||||
print(compute_sum([1,2,3,4,5]))
|
||||
print(compute_sum([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_sum([1,1,1,1,1,1,1]))
|
||||
print(compute_sum([1,2,3,4,5,4,3]))
|
||||
|
||||
print(compute_product([0,0,0]))
|
||||
print(compute_product([1,2,3,4,5]))
|
||||
print(compute_product([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_product([1,1,1,1,1,1,1]))
|
||||
print(compute_product([1,2,3,4,5,4,3]))
|
||||
|
||||
main()
|
||||
@@ -0,0 +1,43 @@
|
||||
def compute_sum(list_: list[int]) -> int:
|
||||
''' function to compute the sum of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the integer sum of the list of integers
|
||||
'''
|
||||
sum_ = 0
|
||||
for i in list_:
|
||||
sum_ += i
|
||||
return sum_
|
||||
|
||||
print(compute_sum([0]))
|
||||
print(compute_sum([1,2,3]))
|
||||
print(compute_sum([-1,-2,-3]))
|
||||
|
||||
def compute_product(list_: list[int]) -> int | None:
|
||||
''' function to compute the product of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the product sum of the list of integers; if the list is
|
||||
empty, we return None
|
||||
'''
|
||||
if len(list_) == 0: return None
|
||||
product = 1
|
||||
for i in list_:
|
||||
product *= i
|
||||
return product
|
||||
|
||||
print(compute_product([0]))
|
||||
print(compute_product([1,2,3]))
|
||||
print(compute_product([-1,-2,-3]))
|
||||
|
||||
def main():
|
||||
value = compute_sum([0])
|
||||
print(value)
|
||||
value = compute_sum([1,2,3])
|
||||
print(value)
|
||||
value = compute_sum([-1,-2,-3])
|
||||
print(value)
|
||||
|
||||
main()
|
||||
@@ -0,0 +1,43 @@
|
||||
def compute_sum(list_: list[int]) -> int:
|
||||
''' function to compute the sum of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the integer sum of the list of integers
|
||||
'''
|
||||
sum_ = 0
|
||||
for i in list_:
|
||||
sum_ += i
|
||||
return sum_
|
||||
|
||||
print(compute_sum([0]))
|
||||
|
||||
print(compute_sum([1,2]))
|
||||
|
||||
print(compute_sum([3,4,5,6,7]))
|
||||
|
||||
print(compute_sum([-3,4,5,6,7]))
|
||||
|
||||
def compute_product(list_: list[int]) -> int | None:
|
||||
''' function to compute the product of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the product sum of the list of integers; if the list is
|
||||
empty, we return None
|
||||
'''
|
||||
if len(list_) == 0: return None
|
||||
product = 1
|
||||
for i in list_:
|
||||
product *= i
|
||||
return product
|
||||
|
||||
print(compute_product([0]))
|
||||
|
||||
print(compute_product([1,2]))
|
||||
|
||||
print(compute_product([3,4,5,6,7]))
|
||||
|
||||
print(compute_product([-3,4,5,6,7]))
|
||||
|
||||
|
||||
43
Lab 1 - Group Work/lab1_files/autograde/lchikh/dcs_lab1.py
Normal file
43
Lab 1 - Group Work/lab1_files/autograde/lchikh/dcs_lab1.py
Normal file
@@ -0,0 +1,43 @@
|
||||
def compute_sum(list_: list[int]) -> int:
|
||||
''' function to compute the sum of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the integer sum of the list of integers
|
||||
'''
|
||||
sum_ = 0
|
||||
for i in list_:
|
||||
sum_ += i
|
||||
return sum_
|
||||
|
||||
print(compute_sum([0]))
|
||||
print(compute_sum([1,2,3]))
|
||||
print(compute_sum([-1,-2,-3]))
|
||||
|
||||
def compute_product(list_: list[int]) -> int | None:
|
||||
''' function to compute the product of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the product sum of the list of integers; if the list is
|
||||
empty, we return None
|
||||
'''
|
||||
if len(list_) == 0: return None
|
||||
product = 1
|
||||
for i in list_:
|
||||
product *= i
|
||||
return product
|
||||
|
||||
print(compute_product([0]))
|
||||
print(compute_product([1,2,3]))
|
||||
print(compute_product([-1,-2,-3]))
|
||||
|
||||
def main():
|
||||
value = compute_sum([0])
|
||||
print(value)
|
||||
value = compute_sum([1,2,3])
|
||||
print(value)
|
||||
value = compute_sum([-1,-2,-3])
|
||||
print(value)
|
||||
|
||||
main()
|
||||
@@ -0,0 +1,56 @@
|
||||
def compute_sum(list_: list[int]) -> int:
|
||||
''' function to compute the sum of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the integer sum of the list of integers
|
||||
'''
|
||||
sum_ = 0
|
||||
for i in list_:
|
||||
sum_ += i
|
||||
return sum_
|
||||
|
||||
print(compute_sum([0,0,0]))
|
||||
print(compute_sum([1,2,3,4,5]))
|
||||
print(compute_sum([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_sum([1,1,1,1,1,1,1]))
|
||||
print(compute_sum([1,2,3,4,5,4,3]))
|
||||
|
||||
def compute_product(list_: list[int]) -> int | None:
|
||||
''' function to compute the product of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the product sum of the list of integers; if the list is
|
||||
empty, we return None
|
||||
'''
|
||||
if len(list_) == 0: return None
|
||||
product = 1
|
||||
for i in list_:
|
||||
product *= i
|
||||
return product
|
||||
|
||||
print(compute_product([0,0,0]))
|
||||
print(compute_product([1,2,3,4,5]))
|
||||
print(compute_product([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_product([1,1,1,1,1,1,1]))
|
||||
print(compute_product([1,2,3,4,5,4,3]))
|
||||
|
||||
def main():
|
||||
print(compute_sum([0,0,0]))
|
||||
print(compute_sum([1,2,3,4,5]))
|
||||
print(compute_sum([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_sum([1,1,1,1,1,1,1]))
|
||||
print(compute_sum([1,2,3,4,5,4,3]))
|
||||
|
||||
print(compute_product([0,0,0]))
|
||||
print(compute_product([1,2,3,4,5]))
|
||||
print(compute_product([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_product([1,1,1,1,1,1,1]))
|
||||
print(compute_product([1,2,3,4,5,4,3]))
|
||||
|
||||
main()
|
||||
43
Lab 1 - Group Work/lab1_files/autograde/lpaynter/lab1.py
Normal file
43
Lab 1 - Group Work/lab1_files/autograde/lpaynter/lab1.py
Normal file
@@ -0,0 +1,43 @@
|
||||
def compute_sum(list_: list[int]) -> int:
|
||||
''' function to compute the sum of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the integer sum of the list of integers
|
||||
'''
|
||||
sum_ = 0
|
||||
for i in list_:
|
||||
sum_ += i
|
||||
return sum_
|
||||
|
||||
print(compute_sum([0]))
|
||||
|
||||
print(compute_sum([1,2]))
|
||||
|
||||
print(compute_sum([3,4,5,6,7]))
|
||||
|
||||
print(compute_sum([-3,4,5,6,7]))
|
||||
|
||||
def compute_product(list_: list[int]) -> int | None:
|
||||
''' function to compute the product of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the product sum of the list of integers; if the list is
|
||||
empty, we return None
|
||||
'''
|
||||
if len(list_) == 0: return None
|
||||
product = 1
|
||||
for i in list_:
|
||||
product *= i
|
||||
return product
|
||||
|
||||
print(compute_product([0]))
|
||||
|
||||
print(compute_product([1,2]))
|
||||
|
||||
print(compute_product([3,4,5,6,7]))
|
||||
|
||||
print(compute_product([-3,4,5,6,7]))
|
||||
|
||||
|
||||
43
Lab 1 - Group Work/lab1_files/autograde/mcory/dcs211_lab1.py
Normal file
43
Lab 1 - Group Work/lab1_files/autograde/mcory/dcs211_lab1.py
Normal file
@@ -0,0 +1,43 @@
|
||||
def compute_sum(list_: list[int]) -> int:
|
||||
''' function to compute the sum of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the integer sum of the list of integers
|
||||
'''
|
||||
sum_ = 0
|
||||
for i in list_:
|
||||
sum_ += i
|
||||
return sum_
|
||||
|
||||
print(compute_sum([0]))
|
||||
|
||||
print(compute_sum([1,2]))
|
||||
|
||||
print(compute_sum([3,4,5,6,7]))
|
||||
|
||||
print(compute_sum([-3,4,5,6,7]))
|
||||
|
||||
def compute_product(list_: list[int]) -> int | None:
|
||||
''' function to compute the product of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the product sum of the list of integers; if the list is
|
||||
empty, we return None
|
||||
'''
|
||||
if len(list_) == 0: return None
|
||||
product = 1
|
||||
for i in list_:
|
||||
product *= i
|
||||
return product
|
||||
|
||||
print(compute_product([0]))
|
||||
|
||||
print(compute_product([1,2]))
|
||||
|
||||
print(compute_product([3,4,5,6,7]))
|
||||
|
||||
print(compute_product([-3,4,5,6,7]))
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
def compute_sum(list_: list[int]) -> int:
|
||||
''' function to compute the sum of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the integer sum of the list of integers
|
||||
'''
|
||||
sum_ = 0
|
||||
for i in list_:
|
||||
sum_ += i
|
||||
return sum_
|
||||
|
||||
print(compute_sum([0]))
|
||||
print(compute_sum([1,2,3]))
|
||||
print(compute_sum([-1,-2,-3]))
|
||||
|
||||
def compute_product(list_: list[int]) -> int | None:
|
||||
''' function to compute the product of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the product sum of the list of integers; if the list is
|
||||
empty, we return None
|
||||
'''
|
||||
if len(list_) == 0: return None
|
||||
product = 1
|
||||
for i in list_:
|
||||
product *= i
|
||||
return product
|
||||
|
||||
print(compute_product([0]))
|
||||
print(compute_product([1,2,3]))
|
||||
print(compute_product([-1,-2,-3]))
|
||||
|
||||
def main():
|
||||
value = compute_sum([0])
|
||||
print(value)
|
||||
value = compute_sum([1,2,3])
|
||||
print(value)
|
||||
value = compute_sum([-1,-2,-3])
|
||||
print(value)
|
||||
|
||||
main()
|
||||
@@ -0,0 +1,56 @@
|
||||
def compute_sum(list_: list[int]) -> int:
|
||||
''' function to compute the sum of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the integer sum of the list of integers
|
||||
'''
|
||||
sum_ = 0
|
||||
for i in list_:
|
||||
sum_ += i
|
||||
return sum_
|
||||
|
||||
print(compute_sum([0,0,0]))
|
||||
print(compute_sum([1,2,3,4,5]))
|
||||
print(compute_sum([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_sum([1,1,1,1,1,1,1]))
|
||||
print(compute_sum([1,2,3,4,5,4,3]))
|
||||
|
||||
def compute_product(list_: list[int]) -> int | None:
|
||||
''' function to compute the product of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the product sum of the list of integers; if the list is
|
||||
empty, we return None
|
||||
'''
|
||||
if len(list_) == 0: return None
|
||||
product = 1
|
||||
for i in list_:
|
||||
product *= i
|
||||
return product
|
||||
|
||||
print(compute_product([0,0,0]))
|
||||
print(compute_product([1,2,3,4,5]))
|
||||
print(compute_product([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_product([1,1,1,1,1,1,1]))
|
||||
print(compute_product([1,2,3,4,5,4,3]))
|
||||
|
||||
def main():
|
||||
print(compute_sum([0,0,0]))
|
||||
print(compute_sum([1,2,3,4,5]))
|
||||
print(compute_sum([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_sum([1,1,1,1,1,1,1]))
|
||||
print(compute_sum([1,2,3,4,5,4,3]))
|
||||
|
||||
print(compute_product([0,0,0]))
|
||||
print(compute_product([1,2,3,4,5]))
|
||||
print(compute_product([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_product([1,1,1,1,1,1,1]))
|
||||
print(compute_product([1,2,3,4,5,4,3]))
|
||||
|
||||
main()
|
||||
@@ -0,0 +1,43 @@
|
||||
def compute_sum(list_: list[int]) -> int:
|
||||
''' function to compute the sum of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the integer sum of the list of integers
|
||||
'''
|
||||
sum_ = 0
|
||||
for i in list_:
|
||||
sum_ += i
|
||||
return sum_
|
||||
|
||||
print(compute_sum([0]))
|
||||
|
||||
print(compute_sum([1,2]))
|
||||
|
||||
print(compute_sum([3,4,5,6,7]))
|
||||
|
||||
print(compute_sum([-3,4,5,6,7]))
|
||||
|
||||
def compute_product(list_: list[int]) -> int | None:
|
||||
''' function to compute the product of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the product sum of the list of integers; if the list is
|
||||
empty, we return None
|
||||
'''
|
||||
if len(list_) == 0: return None
|
||||
product = 1
|
||||
for i in list_:
|
||||
product *= i
|
||||
return product
|
||||
|
||||
print(compute_product([0]))
|
||||
|
||||
print(compute_product([1,2]))
|
||||
|
||||
print(compute_product([3,4,5,6,7]))
|
||||
|
||||
print(compute_product([-3,4,5,6,7]))
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
def compute_sum(list_: list[int]) -> int:
|
||||
''' function to compute the sum of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the integer sum of the list of integers
|
||||
'''
|
||||
sum_ = 0
|
||||
for i in list_:
|
||||
sum_ += i
|
||||
return sum_
|
||||
|
||||
print(compute_sum([0]))
|
||||
print(compute_sum([1,2,3]))
|
||||
print(compute_sum([-1,-2,-3]))
|
||||
|
||||
def compute_product(list_: list[int]) -> int | None:
|
||||
''' function to compute the product of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the product sum of the list of integers; if the list is
|
||||
empty, we return None
|
||||
'''
|
||||
if len(list_) == 0: return None
|
||||
product = 1
|
||||
for i in list_:
|
||||
product *= i
|
||||
return product
|
||||
|
||||
print(compute_product([0]))
|
||||
print(compute_product([1,2,3]))
|
||||
print(compute_product([-1,-2,-3]))
|
||||
|
||||
def main():
|
||||
value = compute_sum([0])
|
||||
print(value)
|
||||
value = compute_sum([1,2,3])
|
||||
print(value)
|
||||
value = compute_sum([-1,-2,-3])
|
||||
print(value)
|
||||
|
||||
main()
|
||||
@@ -0,0 +1,43 @@
|
||||
def compute_sum(list_: list[int]) -> int:
|
||||
''' function to compute the sum of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the integer sum of the list of integers
|
||||
'''
|
||||
sum_ = 0
|
||||
for i in list_:
|
||||
sum_ += i
|
||||
return sum_
|
||||
|
||||
print(compute_sum([0]))
|
||||
|
||||
print(compute_sum([1,2]))
|
||||
|
||||
print(compute_sum([3,4,5,6,7]))
|
||||
|
||||
print(compute_sum([-3,4,5,6,7]))
|
||||
|
||||
def compute_product(list_: list[int]) -> int | None:
|
||||
''' function to compute the product of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the product sum of the list of integers; if the list is
|
||||
empty, we return None
|
||||
'''
|
||||
if len(list_) == 0: return None
|
||||
product = 1
|
||||
for i in list_:
|
||||
product *= i
|
||||
return product
|
||||
|
||||
print(compute_product([0]))
|
||||
|
||||
print(compute_product([1,2]))
|
||||
|
||||
print(compute_product([3,4,5,6,7]))
|
||||
|
||||
print(compute_product([-3,4,5,6,7]))
|
||||
|
||||
|
||||
56
Lab 1 - Group Work/lab1_files/autograde/nzuze/dcs211_lab1.py
Normal file
56
Lab 1 - Group Work/lab1_files/autograde/nzuze/dcs211_lab1.py
Normal file
@@ -0,0 +1,56 @@
|
||||
def compute_sum(list_: list[int]) -> int:
|
||||
''' function to compute the sum of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the integer sum of the list of integers
|
||||
'''
|
||||
sum_ = 0
|
||||
for i in list_:
|
||||
sum_ += i
|
||||
return sum_
|
||||
|
||||
print(compute_sum([0,0,0]))
|
||||
print(compute_sum([1,2,3,4,5]))
|
||||
print(compute_sum([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_sum([1,1,1,1,1,1,1]))
|
||||
print(compute_sum([1,2,3,4,5,4,3]))
|
||||
|
||||
def compute_product(list_: list[int]) -> int | None:
|
||||
''' function to compute the product of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the product sum of the list of integers; if the list is
|
||||
empty, we return None
|
||||
'''
|
||||
if len(list_) == 0: return None
|
||||
product = 1
|
||||
for i in list_:
|
||||
product *= i
|
||||
return product
|
||||
|
||||
print(compute_product([0,0,0]))
|
||||
print(compute_product([1,2,3,4,5]))
|
||||
print(compute_product([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_product([1,1,1,1,1,1,1]))
|
||||
print(compute_product([1,2,3,4,5,4,3]))
|
||||
|
||||
def main():
|
||||
print(compute_sum([0,0,0]))
|
||||
print(compute_sum([1,2,3,4,5]))
|
||||
print(compute_sum([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_sum([1,1,1,1,1,1,1]))
|
||||
print(compute_sum([1,2,3,4,5,4,3]))
|
||||
|
||||
print(compute_product([0,0,0]))
|
||||
print(compute_product([1,2,3,4,5]))
|
||||
print(compute_product([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_product([1,1,1,1,1,1,1]))
|
||||
print(compute_product([1,2,3,4,5,4,3]))
|
||||
|
||||
main()
|
||||
@@ -0,0 +1,56 @@
|
||||
def compute_sum(list_: list[int]) -> int:
|
||||
''' function to compute the sum of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the integer sum of the list of integers
|
||||
'''
|
||||
sum_ = 0
|
||||
for i in list_:
|
||||
sum_ += i
|
||||
return sum_
|
||||
|
||||
print(compute_sum([0,0,0]))
|
||||
print(compute_sum([1,2,3,4,5]))
|
||||
print(compute_sum([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_sum([1,1,1,1,1,1,1]))
|
||||
print(compute_sum([1,2,3,4,5,4,3]))
|
||||
|
||||
def compute_product(list_: list[int]) -> int | None:
|
||||
''' function to compute the product of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the product sum of the list of integers; if the list is
|
||||
empty, we return None
|
||||
'''
|
||||
if len(list_) == 0: return None
|
||||
product = 1
|
||||
for i in list_:
|
||||
product *= i
|
||||
return product
|
||||
|
||||
print(compute_product([0,0,0]))
|
||||
print(compute_product([1,2,3,4,5]))
|
||||
print(compute_product([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_product([1,1,1,1,1,1,1]))
|
||||
print(compute_product([1,2,3,4,5,4,3]))
|
||||
|
||||
def main():
|
||||
print(compute_sum([0,0,0]))
|
||||
print(compute_sum([1,2,3,4,5]))
|
||||
print(compute_sum([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_sum([1,1,1,1,1,1,1]))
|
||||
print(compute_sum([1,2,3,4,5,4,3]))
|
||||
|
||||
print(compute_product([0,0,0]))
|
||||
print(compute_product([1,2,3,4,5]))
|
||||
print(compute_product([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_product([1,1,1,1,1,1,1]))
|
||||
print(compute_product([1,2,3,4,5,4,3]))
|
||||
|
||||
main()
|
||||
@@ -0,0 +1,56 @@
|
||||
def compute_sum(list_: list[int]) -> int:
|
||||
''' function to compute the sum of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the integer sum of the list of integers
|
||||
'''
|
||||
sum_ = 0
|
||||
for i in list_:
|
||||
sum_ += i
|
||||
return sum_
|
||||
|
||||
print(compute_sum([0,0,0]))
|
||||
print(compute_sum([1,2,3,4,5]))
|
||||
print(compute_sum([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_sum([1,1,1,1,1,1,1]))
|
||||
print(compute_sum([1,2,3,4,5,4,3]))
|
||||
|
||||
def compute_product(list_: list[int]) -> int | None:
|
||||
''' function to compute the product of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the product sum of the list of integers; if the list is
|
||||
empty, we return None
|
||||
'''
|
||||
if len(list_) == 0: return None
|
||||
product = 1
|
||||
for i in list_:
|
||||
product *= i
|
||||
return product
|
||||
|
||||
print(compute_product([0,0,0]))
|
||||
print(compute_product([1,2,3,4,5]))
|
||||
print(compute_product([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_product([1,1,1,1,1,1,1]))
|
||||
print(compute_product([1,2,3,4,5,4,3]))
|
||||
|
||||
def main():
|
||||
print(compute_sum([0,0,0]))
|
||||
print(compute_sum([1,2,3,4,5]))
|
||||
print(compute_sum([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_sum([1,1,1,1,1,1,1]))
|
||||
print(compute_sum([1,2,3,4,5,4,3]))
|
||||
|
||||
print(compute_product([0,0,0]))
|
||||
print(compute_product([1,2,3,4,5]))
|
||||
print(compute_product([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_product([1,1,1,1,1,1,1]))
|
||||
print(compute_product([1,2,3,4,5,4,3]))
|
||||
|
||||
main()
|
||||
@@ -0,0 +1,56 @@
|
||||
def compute_sum(list_: list[int]) -> int:
|
||||
''' function to compute the sum of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the integer sum of the list of integers
|
||||
'''
|
||||
sum_ = 0
|
||||
for i in list_:
|
||||
sum_ += i
|
||||
return sum_
|
||||
|
||||
print(compute_sum([0,0,0]))
|
||||
print(compute_sum([1,2,3,4,5]))
|
||||
print(compute_sum([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_sum([1,1,1,1,1,1,1]))
|
||||
print(compute_sum([1,2,3,4,5,4,3]))
|
||||
|
||||
def compute_product(list_: list[int]) -> int | None:
|
||||
''' function to compute the product of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the product sum of the list of integers; if the list is
|
||||
empty, we return None
|
||||
'''
|
||||
if len(list_) == 0: return None
|
||||
product = 1
|
||||
for i in list_:
|
||||
product *= i
|
||||
return product
|
||||
|
||||
print(compute_product([0,0,0]))
|
||||
print(compute_product([1,2,3,4,5]))
|
||||
print(compute_product([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_product([1,1,1,1,1,1,1]))
|
||||
print(compute_product([1,2,3,4,5,4,3]))
|
||||
|
||||
def main():
|
||||
print(compute_sum([0,0,0]))
|
||||
print(compute_sum([1,2,3,4,5]))
|
||||
print(compute_sum([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_sum([1,1,1,1,1,1,1]))
|
||||
print(compute_sum([1,2,3,4,5,4,3]))
|
||||
|
||||
print(compute_product([0,0,0]))
|
||||
print(compute_product([1,2,3,4,5]))
|
||||
print(compute_product([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_product([1,1,1,1,1,1,1]))
|
||||
print(compute_product([1,2,3,4,5,4,3]))
|
||||
|
||||
main()
|
||||
@@ -0,0 +1,43 @@
|
||||
def compute_sum(list_: list[int]) -> int:
|
||||
''' function to compute the sum of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the integer sum of the list of integers
|
||||
'''
|
||||
sum_ = 0
|
||||
for i in list_:
|
||||
sum_ += i
|
||||
return sum_
|
||||
|
||||
print(compute_sum([0]))
|
||||
print(compute_sum([1,2,3]))
|
||||
print(compute_sum([-1,-2,-3]))
|
||||
|
||||
def compute_product(list_: list[int]) -> int | None:
|
||||
''' function to compute the product of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the product sum of the list of integers; if the list is
|
||||
empty, we return None
|
||||
'''
|
||||
if len(list_) == 0: return None
|
||||
product = 1
|
||||
for i in list_:
|
||||
product *= i
|
||||
return product
|
||||
|
||||
print(compute_product([0]))
|
||||
print(compute_product([1,2,3]))
|
||||
print(compute_product([-1,-2,-3]))
|
||||
|
||||
def main():
|
||||
value = compute_sum([0])
|
||||
print(value)
|
||||
value = compute_sum([1,2,3])
|
||||
print(value)
|
||||
value = compute_sum([-1,-2,-3])
|
||||
print(value)
|
||||
|
||||
main()
|
||||
@@ -0,0 +1,43 @@
|
||||
def compute_sum(list_: list[int]) -> int:
|
||||
''' function to compute the sum of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the integer sum of the list of integers
|
||||
'''
|
||||
sum_ = 0
|
||||
for i in list_:
|
||||
sum_ += i
|
||||
return sum_
|
||||
|
||||
print(compute_sum([0]))
|
||||
print(compute_sum([1,2,3]))
|
||||
print(compute_sum([-1,-2,-3]))
|
||||
|
||||
def compute_product(list_: list[int]) -> int | None:
|
||||
''' function to compute the product of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the product sum of the list of integers; if the list is
|
||||
empty, we return None
|
||||
'''
|
||||
if len(list_) == 0: return None
|
||||
product = 1
|
||||
for i in list_:
|
||||
product *= i
|
||||
return product
|
||||
|
||||
print(compute_product([0]))
|
||||
print(compute_product([1,2,3]))
|
||||
print(compute_product([-1,-2,-3]))
|
||||
|
||||
def main():
|
||||
value = compute_sum([0])
|
||||
print(value)
|
||||
value = compute_sum([1,2,3])
|
||||
print(value)
|
||||
value = compute_sum([-1,-2,-3])
|
||||
print(value)
|
||||
|
||||
main()
|
||||
43
Lab 1 - Group Work/lab1_files/autograde/srice/dcs211_lab1.py
Normal file
43
Lab 1 - Group Work/lab1_files/autograde/srice/dcs211_lab1.py
Normal file
@@ -0,0 +1,43 @@
|
||||
def compute_sum(list_: list[int]) -> int:
|
||||
''' function to compute the sum of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the integer sum of the list of integers
|
||||
'''
|
||||
sum_ = 0
|
||||
for i in list_:
|
||||
sum_ += i
|
||||
return sum_
|
||||
|
||||
print(compute_sum([0]))
|
||||
|
||||
print(compute_sum([1,2]))
|
||||
|
||||
print(compute_sum([3,4,5,6,7]))
|
||||
|
||||
print(compute_sum([-3,4,5,6,7]))
|
||||
|
||||
def compute_product(list_: list[int]) -> int | None:
|
||||
''' function to compute the product of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the product sum of the list of integers; if the list is
|
||||
empty, we return None
|
||||
'''
|
||||
if len(list_) == 0: return None
|
||||
product = 1
|
||||
for i in list_:
|
||||
product *= i
|
||||
return product
|
||||
|
||||
print(compute_product([0]))
|
||||
|
||||
print(compute_product([1,2]))
|
||||
|
||||
print(compute_product([3,4,5,6,7]))
|
||||
|
||||
print(compute_product([-3,4,5,6,7]))
|
||||
|
||||
|
||||
27
Lab 1 - Group Work/lab1_files/autograde/students.txt
Normal file
27
Lab 1 - Group Work/lab1_files/autograde/students.txt
Normal file
@@ -0,0 +1,27 @@
|
||||
zali Zain Ali
|
||||
eamini Edward Amini
|
||||
lbaron Liam Baron
|
||||
lchikh Leith Rouhou
|
||||
mcory Max Cory
|
||||
mdonaghy Megan Donaghy
|
||||
oenkhorgil Yuka Enkh-Orgil
|
||||
rgleason Ryan Gleason
|
||||
lhrinda Luke Hrinda
|
||||
shughes2 Sarah Hughes
|
||||
jjiang Jerry Jiang
|
||||
ckenny Chris Kenny
|
||||
tleamon Ted Leamon
|
||||
mlogan Miles Logan
|
||||
smaquera Sara Maquera
|
||||
fmiele Fran Miele
|
||||
mnijjer Mehar Nijjer
|
||||
lpaynter Lucy Paynter
|
||||
oputnambagley Lando Putnam-Bagley
|
||||
areed2 Andrew Reed
|
||||
srice Sam Rice
|
||||
jroelofs Julia Roelofs
|
||||
tshapiro Teddy Shapiro
|
||||
mshimizu Micah Shimizu
|
||||
jtapiamarte Juan Carlos Tapia Marte
|
||||
myoung2 Malina Young
|
||||
nzuze Noku Zuze
|
||||
@@ -0,0 +1,43 @@
|
||||
def compute_sum(list_: list[int]) -> int:
|
||||
''' function to compute the sum of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the integer sum of the list of integers
|
||||
'''
|
||||
sum_ = 0
|
||||
for i in list_:
|
||||
sum_ += i
|
||||
return sum_
|
||||
|
||||
print(compute_sum([0]))
|
||||
print(compute_sum([1,2,3]))
|
||||
print(compute_sum([-1,-2,-3]))
|
||||
|
||||
def compute_product(list_: list[int]) -> int | None:
|
||||
''' function to compute the product of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the product sum of the list of integers; if the list is
|
||||
empty, we return None
|
||||
'''
|
||||
if len(list_) == 0: return None
|
||||
product = 1
|
||||
for i in list_:
|
||||
product *= i
|
||||
return product
|
||||
|
||||
print(compute_product([0]))
|
||||
print(compute_product([1,2,3]))
|
||||
print(compute_product([-1,-2,-3]))
|
||||
|
||||
def main():
|
||||
value = compute_sum([0])
|
||||
print(value)
|
||||
value = compute_sum([1,2,3])
|
||||
print(value)
|
||||
value = compute_sum([-1,-2,-3])
|
||||
print(value)
|
||||
|
||||
main()
|
||||
@@ -0,0 +1,43 @@
|
||||
def compute_sum(list_: list[int]) -> int:
|
||||
''' function to compute the sum of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the integer sum of the list of integers
|
||||
'''
|
||||
sum_ = 0
|
||||
for i in list_:
|
||||
sum_ += i
|
||||
return sum_
|
||||
|
||||
print(compute_sum([0]))
|
||||
|
||||
print(compute_sum([1,2]))
|
||||
|
||||
print(compute_sum([3,4,5,6,7]))
|
||||
|
||||
print(compute_sum([-3,4,5,6,7]))
|
||||
|
||||
def compute_product(list_: list[int]) -> int | None:
|
||||
''' function to compute the product of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the product sum of the list of integers; if the list is
|
||||
empty, we return None
|
||||
'''
|
||||
if len(list_) == 0: return None
|
||||
product = 1
|
||||
for i in list_:
|
||||
product *= i
|
||||
return product
|
||||
|
||||
print(compute_product([0]))
|
||||
|
||||
print(compute_product([1,2]))
|
||||
|
||||
print(compute_product([3,4,5,6,7]))
|
||||
|
||||
print(compute_product([-3,4,5,6,7]))
|
||||
|
||||
|
||||
56
Lab 1 - Group Work/lab1_files/autograde/zali/dcs211_lab1.py
Normal file
56
Lab 1 - Group Work/lab1_files/autograde/zali/dcs211_lab1.py
Normal file
@@ -0,0 +1,56 @@
|
||||
def compute_sum(list_: list[int]) -> int:
|
||||
''' function to compute the sum of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the integer sum of the list of integers
|
||||
'''
|
||||
sum_ = 0
|
||||
for i in list_:
|
||||
sum_ += i
|
||||
return sum_
|
||||
|
||||
print(compute_sum([0,0,0]))
|
||||
print(compute_sum([1,2,3,4,5]))
|
||||
print(compute_sum([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_sum([1,1,1,1,1,1,1]))
|
||||
print(compute_sum([1,2,3,4,5,4,3]))
|
||||
|
||||
def compute_product(list_: list[int]) -> int | None:
|
||||
''' function to compute the product of a list of integers
|
||||
Parameters:
|
||||
list_: a list of integers
|
||||
Returns:
|
||||
the product sum of the list of integers; if the list is
|
||||
empty, we return None
|
||||
'''
|
||||
if len(list_) == 0: return None
|
||||
product = 1
|
||||
for i in list_:
|
||||
product *= i
|
||||
return product
|
||||
|
||||
print(compute_product([0,0,0]))
|
||||
print(compute_product([1,2,3,4,5]))
|
||||
print(compute_product([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_product([1,1,1,1,1,1,1]))
|
||||
print(compute_product([1,2,3,4,5,4,3]))
|
||||
|
||||
def main():
|
||||
print(compute_sum([0,0,0]))
|
||||
print(compute_sum([1,2,3,4,5]))
|
||||
print(compute_sum([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_sum([1,1,1,1,1,1,1]))
|
||||
print(compute_sum([1,2,3,4,5,4,3]))
|
||||
|
||||
print(compute_product([0,0,0]))
|
||||
print(compute_product([1,2,3,4,5]))
|
||||
print(compute_product([-1,-2,-3,-4,-5]))
|
||||
|
||||
print(compute_product([1,1,1,1,1,1,1]))
|
||||
print(compute_product([1,2,3,4,5,4,3]))
|
||||
|
||||
main()
|
||||
Reference in New Issue
Block a user