Lab #5¶
Before Kattis¶
1
Write a function called count_to_n_w(n)
to print a count from 0 to n-1
. This function should use a while loop.
2
Write a function called add_one_n_times_w(a, n)
that will add one to a number a
a total of n
times. In the end, have this function return
the value. This function must use a while
loop. It should work such that:
>>> ans = add_one_n_times(7, 5)
>>> print(ans)
12
3
Write a function called count_to_n_f(n)
to print a count from 0 to n-1
. This function should use a for loop. Hint: check out range.
4
Write another function called add_one_n_times_f(a, n)
that will add one to a number a
a total of n
times, but this time with a for
loop.
Kattis Problems¶
Grab a scrap piece of paper to start scratching your ideas down on paper. The problems are getting tricky enough where this really is becoming a requirement.
https://open.kattis.com/problems/sibice (Think about how you would do this real life before you start coding)
https://open.kattis.com/problems/datum (more annoying than tough)
https://open.kattis.com/problems/dicecup (tough – grab that paper)
ENSURE WE HAVE RECORDED YOUR COMPLETION. FAILURE TO DO SO WILL RESULT IN A GRADE OF 0!