How do functions help you to reuse code in a program?

1 answer

Answer

1141901

2026-05-16 10:20

+ Follow

Functions hold code, which means anything that happens within a function can be "called" later on. Allowing the programmer to save time, and ensuring he doesn't have to re-write code. Example:

Instead of writing "Hello" 10 times, I made a function that said print("hello") 5 times, then "Called" the function twice.

def helloFiveTimes():

print("Hello")

print("Hello")

print("Hello")

print("Hello")

print("Hello")

return

helloFiveTimes()

helloFiveTimes()

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.