Escrito por estudiantes que aprobaron Inmediatamente disponible después del pago Leer en línea o como PDF ¿Documento equivocado? Cámbialo gratis 4,6 TrustPilot
logo-home
Examen

CPSC 217 FINAL | LATEST STUDY | QUESTIONS AND ANSWERS | 2026 STUDY UPDATES

Puntuación
-
Vendido
-
Páginas
23
Grado
A+
Subido en
19-01-2026
Escrito en
2025/2026

CPSC 217 FINAL | LATEST STUDY | QUESTIONS AND ANSWERS | 2026 STUDY UPDATES

Institución
CPSC 217
Grado
CPSC 217

Vista previa del contenido

CPSC 217 FINAL | LATEST STUDY | QUESTIONS AND
ANSWERS | 2026 STUDY UPDATES
What is the best way to create functions for a program? Give example - ANSWER- Top
down approach, break it down into parts



ex. Program to calculate interest, break it into 3 functions

1. Get info

2. Do Calculations

3. Display results

What is the result of and how does it work?



def displayInstructions ( ):

print ("Displaying instructions")



displayInstructions ( )

print ("End") - ANSWER- You created a function called displayIntructions. The body of that
function has the print function in it which will have the output of: "Displaying instructions"

Then you called on your newly defined function, so this executes the function (ie, its body) and
then the last output is: "End"

True or false: once a function is executed one time, it can't be called again, even if you try and
call the function multiple times. - ANSWER- False! You can reuse a function as many times
as you want/is called

What is the difference between a local variable and global variable? - ANSWER- Local
variables are stored within function bodies.

Global variables are generally defined at the beginning of the code and can be accessed anytime

,Why have local variables? - ANSWER- Since variables are memory locations, they take up
a portion of memory of the program. So by creating local variables, the memory is used up
temporarily, and then once the function is executed, that memory frees up.

When a constant or a variable is in scope, we really mean...Give example - ANSWER- It is
somewhere that it can be used. Ex. a local variable is in scope of the function it is under

What is parameter passing? What's often forgotten (2)? - ANSWER- Passing local variables
from one function to another.

The number of parameters passed into a function, must equal the number of
parameters/variables that are called on. It also needs to match exactly what is called on in the
start function.

Is this correct:



def start ( ):

print (num) - ANSWER- No, no parameter 'num' passed into start, so it can't access that
memory location called 'num'.



To fix it, must have:

def start (num):

print (num)

What does the return function do? What is often forgotten?

Give example - ANSWER- It communicates a copy of information out of a function (back to
caller) as function ends.



THE RETURN VALUE MUST BE STORED IN THE START FUNCTION




def square (num):

result = num * num

, return (result)



def start ( ):

aStr = input ("Enter a number: ")

num = int(aStr)

*result* = square (num)

print (result)

Difference between parameter passing and return values? - ANSWER- Parameter passing
passes info INTO function before it executes (passes memory location of variable into function)



Return values communicate info OUT of a function as the function ends

What are some good style of functions that should be implemented? - ANSWER- 1.
Function should have a well defined task

2. Have a self-descriptive name

3. No longer than 1 screen

4. Use variable naming conventions (lower case, camel-case, or underscore)

Why should you not use global variables? Give an example - ANSWER- Can accidentally be
changed anywhere - since they can be accessed from anywhere, makes code harder to trace



num = 1



def fun ( ):

*global* num #calls in global num

num = 2 #changes global num from 1 to 2

print (num)



def start ( ):

Escuela, estudio y materia

Institución
CPSC 217
Grado
CPSC 217

Información del documento

Subido en
19 de enero de 2026
Número de páginas
23
Escrito en
2025/2026
Tipo
Examen
Contiene
Preguntas y respuestas

Temas

$16.49
Accede al documento completo:

¿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

Conoce al vendedor

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.
EduSprint Chamberlain College Of Nursing
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
39
Miembro desde
2 año
Número de seguidores
6
Documentos
6465
Última venta
3 días hace
STUDY_STASH

4.3

6 reseñas

5
4
4
0
3
2
2
0
1
0

Documentos populares

Recientemente visto por ti

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