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_all
low
and high
low
and high
summing all values (HINT: you need to create a variable that will aggregate or accumulate the sum)low
and high
while
(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.
Write a function called count_vowels
that takes a string as argument, and returns an integer with the number of vowels in the string.
HINT: use in
to determine if a character is a vowel
vowels_only
string
argumentstring
argumentindex
before the loop, use index in the while
condition, change index
inside the loop)Write more test cases for this function.
factorial
number
number
1 * 2 * 3 * 4 = 24
while
Write more test cases for this function.
Submit your factorial
function to Gradescope for attendance.
Name your file factorial.py
power
base
and exp
base
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.