Garantie de satisfaction à 100% Disponible immédiatement après paiement En ligne et en PDF Tu n'es attaché à rien 4,6 TrustPilot
logo-home
Examen

CS 1101 Unit 3 Programming Assignment: Full Solutions & Study Guide for 2026/2027

Note
-
Vendu
-
Pages
5
Grade
A+
Publié le
04-01-2026
Écrit en
2025/2026

Master the CS 1101 Unit 3 Programming Assignment with this complete guide. This resource includes detailed solutions, programming concepts, and expert tips to help you complete the assignment successfully and sharpen your coding skills for the 2026/2027 academic year.

Montrer plus Lire moins
Établissement
Computer Tech
Cours
Computer Tech









Oups ! Impossible de charger votre document. Réessayez ou contactez le support.

École, étude et sujet

Établissement
Computer Tech
Cours
Computer Tech

Infos sur le Document

Publié le
4 janvier 2026
Nombre de pages
5
Écrit en
2025/2026
Type
Examen
Contient
Questions et réponses

Sujets

  • cs 1101 unit 3 assignment

Aperçu du contenu

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)

# 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()
$8.49
Accéder à l'intégralité du document:

Garantie de satisfaction à 100%
Disponible immédiatement après paiement
En ligne et en PDF
Tu n'es attaché à rien

Faites connaissance avec le vendeur

Seller avatar
Les scores de réputation sont basés sur le nombre de documents qu'un vendeur a vendus contre paiement ainsi que sur les avis qu'il a reçu pour ces documents. Il y a trois niveaux: Bronze, Argent et Or. Plus la réputation est bonne, plus vous pouvez faire confiance sur la qualité du travail des vendeurs.
allowaysbest stuvia
Voir profil
S'abonner Vous devez être connecté afin de suivre les étudiants ou les cours
Vendu
1902
Membre depuis
5 mois
Nombre de followers
0
Documents
550
Dernière vente
2 jours de cela

4.7

535 revues

5
404
4
119
3
8
2
4
1
0

Récemment consulté par vous

Pourquoi les étudiants choisissent Stuvia

Créé par d'autres étudiants, vérifié par les avis

Une qualité sur laquelle compter : rédigé par des étudiants qui ont réussi et évalué par d'autres qui ont utilisé ce document.

Le document ne convient pas ? Choisis un autre document

Aucun souci ! Tu peux sélectionner directement un autre document qui correspond mieux à ce que tu cherches.

Paye comme tu veux, apprends aussitôt

Aucun abonnement, aucun engagement. Paye selon tes habitudes par carte de crédit et télécharge ton document PDF instantanément.

Student with book image

“Acheté, téléchargé et réussi. C'est aussi simple que ça.”

Alisha Student

Foire aux questions