total = 0
index = 1
while index <= 5:
print('adding ' + str(index))
total = total + index
index = index + 1
print(total)adding 1
adding 2
adding 3
adding 4
adding 5
15
while loopswhile loops with aggregationsum_alllow and highlow and high summing all values (HINT: you need to create a variable that will aggregate or accumulate the sum)low and highwhile (define an index before the loop, use index in the while condition, change the index inside the loop)Write more test cases for this function.
vowels_onlystring argumentstring argumentindex before the loop, use index in the while condition, change index inside the loop)Write more test cases for this function.
factorialnumbernumber1 * 2 * 3 * 4 = 24whileWrite more test cases for this function.
Submit your factorial function to Gradescope for attendance.
Name your file factorial.py
powerbase and expbase to the power of exp** operator, use a while loop (define an index before the loop, use index in the while condition, change index inside the loop)Write more test cases for this function.
def power(base, exp):
result = 1
index = 1
while index <= exp:
result *= base
index += 1
return result
def main():
print( power(2, 3) ) # 8
print( power(3, 3) ) # 27
main()8
27