Unit 1 Session 2 (Click for link to problem statements)
Understand what the interviewer is asking for by using test cases and questions about the problem.
Plan the solution with appropriate visualizations and pseudocode.
General Idea: Loop from 5 to 100, stepping up by 5 each time.
Alternate Idea:: Loop from 5 to 100. If a number is divisible by 5, print the number.
def multiples_of_five():
for num in range(5, 101, 5):
print(num)
print(multiples_of_five())
# Output:
# 5
# 10
# 15
# 20
# 25
# 30
# 35
# 40 ....
# 100
Alternative Solution:
def multiples_of_five():
for num in range(5, 101):
if num % 5 == 0:
print(num)
print(multiples_of_five())
# Output:
# 5
# 10
# 15
# 20
# 25
# 30
# 35
# 40 ....
# 100