• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 2 fuera de 5 páginas
Examen

CS 1101 Unit 3 Programming Assignment 2026/2027 | Programming Study Guide, Solutions & Assignment Review

Document preview thumbnail
Vista previa 2 fuera de 5 páginas

CS 1101 Unit 3 Programming Assignment 2026/2027 | Programming Study Guide, Solutions & Assignment Review

Vista previa del contenido

*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
4:03:13 AM1
4:03:13
of 5Page
AM1
4:03:13
of1CS
5Page
AM1
1101
of1CS
5Page
–1101
Unit
1CS–
3 Programming
1101
Unit –
3 Programming
UnitAssignment.pdf2026/10/23Page
3 Programming
Assignment.pdf2026/10/23Page
Assignment.pdf2026/10/23Page
1 of 5 1 of 5 1 of 5



______________________________________________________!@#!@!~~~~~~~~~~~~~~



CS 1101 – Unit 3 Programming Assignment

CS 1001 - Programming Fundamentals




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




*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
4:03:13 AM1
4:03:13
of 5Page
AM1
4:03:13
of1CS
5Page
AM1
1101
of1CS
5Page
–1101
Unit
1CS–
3 Programming
1101
Unit –
3 Programming
UnitAssignment.pdf2026/10/23Page
3 Programming
Assignment.pdf2026/10/23Page
Assignment.pdf2026/10/23Page
1 of 5 1 of 5 1 of 5

, *@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
4:03:13 AM2
4:03:13
of 5Page
AM2
4:03:13
of2CS
5Page
AM2
1101
of2CS
5Page
–1101
Unit
2CS–
3 Programming
1101
Unit –
3 Programming
UnitAssignment.pdf2026/10/23Page
3 Programming
Assignment.pdf2026/10/23Page
Assignment.pdf2026/10/23Page
2 of 5 2 of 5 2 of 5



______________________________________________________!@#!@!~~~~~~~~~~~~~~


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,
*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
*@*^%^#!*&^*&^!()(@*&$*@10/23/2026,
4:03:13 AM2
4:03:13
of 5Page
AM2
4:03:13
of2CS
5Page
AM2
1101
of2CS
5Page
–1101
Unit
2CS–
3 Programming
1101
Unit –
3 Programming
UnitAssignment.pdf2026/10/23Page
3 Programming
Assignment.pdf2026/10/23Page
Assignment.pdf2026/10/23Page
2 of 5 2 of 5 2 of 5

Información del documento

Subido en
26 de octubre de 2026
Número de páginas
5
Escrito en
2026/2027
Tipo
Examen
Contiene
Preguntas y respuestas
$10.99

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
aumiran0
4.7
(144)
Vendido
1185
Seguidores
3
Artículos
654
Última venta
1 semana hace



Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes