10/23/2026,
*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
7:38:58
*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
AM*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
4:03:13 4:03:13
AM1 of4:03:13
AM1
5Page
of 1CS
AM1
5Page
1101
of 1CS
5Page
–
1101
Unit
1CS –
31101
Programming
Unit–
3 Programming
Unit 3Assignment.docx2026/10/23Page
Programming
Assignment.docx2026/10/23Page
Assignment.docx2026/10/23Page
1 of 5 1 of 5 1 of 5
CS 1101 – Unit 3 Programming Assignment
Benjamin Ifeoluwa Adebayo
University of the People
CS 1001 - Programming Fundamentals
1st December, 2025
Part 1: Countdown and Countup Recursive Functions
Explanation of the Code
This program explores the concept of recursion, where a function calls itself to solve a problem.
The assignment requires two recursive functions:
1. countdown(n): Given in the text, this function prints a number and calls itself with n-1
until it reaches 0.
2. countup(n): This new function accepts a negative number. It prints the number and calls
itself with n+1 (incrementing toward zero) until the base case is reached.
The program creates a decision control process using conditional execution. It accepts user input;
if the number is positive, it triggers countdown; if negative, it triggers countup.
Choice for Zero
For an input of zero, I chose to call the countdown function. Logically, "Blastoff!" represents the
end of a countdown timer. Since 0 implies no time is remaining, triggering the completion message
immediately via countdown is the most semantic choice.
Python Code for Part 1
# Function to count down from a positive number
def countdown(n):
if n <= 0:
print('Blastoff!')
else:
print(n)
countdown(n - 1)
# Function to count up from a negative number
def countup(n):
if n >= 0:
print('Blastoff!')
else:
print(n)
countup(n + 1)
*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
Page 1 of 5*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
4:03:13 AM1 4:03:13
of4:03:13
5PageAM1
1CS
AM1of1101
of
5Page
5Page
–1CS
Unit
1CS 1101
31101
Programming
–
–Unit
Unit33
Programming
Assignment.docx2026/10/23Page
ProgrammingAssignment.docx2026/10/23Page
Assignment.docx2026/10/23Page
1 of 5 11
ofof
55
,10/23/2026,
*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
7:38:58
*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
AM*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
4:03:13 4:03:13
AM2 of4:03:13
AM2
5Page
of 2CS
AM2
5Page
1101
of 2CS
5Page
–
1101
Unit
2CS –
31101
Programming
Unit–
3 Programming
Unit 3Assignment.docx2026/10/23Page
Programming
Assignment.docx2026/10/23Page
Assignment.docx2026/10/23Page
2 of 5 2 of 5 2 of 5
# Main program logic
def start_program():
# Getting input from the user
user_input = input("Please enter a number: ")
# Converting string input to integer
try:
n = int(user_input)
if n > 0:
print("Counting down:")
countdown(n)
elif n < 0:
print("Counting up:")
countup(n)
else:
# Choice for zero: calling countdown to signal immediate completion
print("Input is zero:")
countdown(n)
except ValueError:
print("Please enter a valid integer.")
# Call the function to run the program
start_program()
*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
Page 2 of 5*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
4:03:13 AM2 4:03:13
of4:03:13
5PageAM2
2CS
AM2of1101
of
5Page
5Page
–2CS
Unit
2CS 1101
31101
Programming
–
–Unit
Unit33
Programming
Assignment.docx2026/10/23Page
ProgrammingAssignment.docx2026/10/23Page
Assignment.docx2026/10/23Page
2 of 5 22
ofof
55
*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
7:38:58
*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
AM*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
4:03:13 4:03:13
AM1 of4:03:13
AM1
5Page
of 1CS
AM1
5Page
1101
of 1CS
5Page
–
1101
Unit
1CS –
31101
Programming
Unit–
3 Programming
Unit 3Assignment.docx2026/10/23Page
Programming
Assignment.docx2026/10/23Page
Assignment.docx2026/10/23Page
1 of 5 1 of 5 1 of 5
CS 1101 – Unit 3 Programming Assignment
Benjamin Ifeoluwa Adebayo
University of the People
CS 1001 - Programming Fundamentals
1st December, 2025
Part 1: Countdown and Countup Recursive Functions
Explanation of the Code
This program explores the concept of recursion, where a function calls itself to solve a problem.
The assignment requires two recursive functions:
1. countdown(n): Given in the text, this function prints a number and calls itself with n-1
until it reaches 0.
2. countup(n): This new function accepts a negative number. It prints the number and calls
itself with n+1 (incrementing toward zero) until the base case is reached.
The program creates a decision control process using conditional execution. It accepts user input;
if the number is positive, it triggers countdown; if negative, it triggers countup.
Choice for Zero
For an input of zero, I chose to call the countdown function. Logically, "Blastoff!" represents the
end of a countdown timer. Since 0 implies no time is remaining, triggering the completion message
immediately via countdown is the most semantic choice.
Python Code for Part 1
# Function to count down from a positive number
def countdown(n):
if n <= 0:
print('Blastoff!')
else:
print(n)
countdown(n - 1)
# Function to count up from a negative number
def countup(n):
if n >= 0:
print('Blastoff!')
else:
print(n)
countup(n + 1)
*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
Page 1 of 5*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
4:03:13 AM1 4:03:13
of4:03:13
5PageAM1
1CS
AM1of1101
of
5Page
5Page
–1CS
Unit
1CS 1101
31101
Programming
–
–Unit
Unit33
Programming
Assignment.docx2026/10/23Page
ProgrammingAssignment.docx2026/10/23Page
Assignment.docx2026/10/23Page
1 of 5 11
ofof
55
,10/23/2026,
*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
7:38:58
*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
AM*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
4:03:13 4:03:13
AM2 of4:03:13
AM2
5Page
of 2CS
AM2
5Page
1101
of 2CS
5Page
–
1101
Unit
2CS –
31101
Programming
Unit–
3 Programming
Unit 3Assignment.docx2026/10/23Page
Programming
Assignment.docx2026/10/23Page
Assignment.docx2026/10/23Page
2 of 5 2 of 5 2 of 5
# Main program logic
def start_program():
# Getting input from the user
user_input = input("Please enter a number: ")
# Converting string input to integer
try:
n = int(user_input)
if n > 0:
print("Counting down:")
countdown(n)
elif n < 0:
print("Counting up:")
countup(n)
else:
# Choice for zero: calling countdown to signal immediate completion
print("Input is zero:")
countdown(n)
except ValueError:
print("Please enter a valid integer.")
# Call the function to run the program
start_program()
*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
Page 2 of 5*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
4:03:13 AM2 4:03:13
of4:03:13
5PageAM2
2CS
AM2of1101
of
5Page
5Page
–2CS
Unit
2CS 1101
31101
Programming
–
–Unit
Unit33
Programming
Assignment.docx2026/10/23Page
ProgrammingAssignment.docx2026/10/23Page
Assignment.docx2026/10/23Page
2 of 5 22
ofof
55