CGS 3465 Final Exam

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/118

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 6:03 AM on 4/29/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

119 Terms

1
New cards

what is an operating system

A software which allows the computer to interact with the user, so

that the user can do such things as delete files, start up Python, etc.

2
New cards

What is a computer program, and what is a computer programming language

A program is a list of commands to a computer/microwave/car, etc.

A computer programming language is a set of rules and

conventions for making such programs.

3
New cards

What makes a programming language "higher" than another

A programming language is "higher" than another if the language

allows you to be more human like (English/Spanish) ,

and allows you to do more in one step or command.

4
New cards

what is an IDE.

An IDE is short for interactive development environment

and is a tool to create and run programs.

5
New cards

what is a path variable

lists of (folders/locations) which the computer uses to search for stuff.

6
New cards

What was the first computer, the eniac, developed to do ?

make war (be used for military warfare)

7
New cards

what is "volatile" memory or "random access" memory or "RAM"?

Places in the computer to hold information likely to get reset/lost when the program that uses it stops, and certainly will

when computer is turned off.

8
New cards

What is a drive?

a "secondary" storage device which can be inside

or outside the computer, that holds data in a non-volatile way

(sticks around even when computer is off).

9
New cards

Fill in the blank

A molecule of water is to water what a ______ of memory is to memory.

bit

10
New cards

If there are 12 months in the year, then how many bits of memory would

be required to represent what "month" a student is born in?

4 bits b/c: 4 is 2 to the fourth is 16 (enough) and 2 to the third is only 8 (not enough)

11
New cards

what is binary 1101 in decimal

what is binary 101 in decimal?

13 and 5

12
New cards

what is 12 decimal written as binary?

what is 7 decimal written as binary?

1100 and 111

13
New cards

Is it reasonable to store an ascii character value in a byte?

yes, done all the time

14
New cards

What is a popular convention set that associates 8 bit binary bit patterns to different characters?

ascii

15
New cards

what exactly does the CPU do?

The cpu runs programs, analogous to our trains of thought,

which determine what equipment does what, much as our brain

runs trains of thought which cause our arms and legs to move.

By running programs, the cpu bosses around the rest of the computer

16
New cards

What size of memory is the least amount of memory that has an address/name that machine code can refer to?

a "word" of memory

17
New cards

What size of memory does a computer typically use to store an integer for floating point value?

again a word of memory even though it is not uncommon to use two words for greater accuracy on floats, and greater range for ints.

18
New cards

True/False

Two common word sizes are 32 and 64 bits, and of course the larger word size allows greater precision and greater

range for values stored.

True

19
New cards

Which term (hardware or software) do the following belong to:

a printer

the computer case

Mac OS

IDLE

a cable

a printer - hardware

the computer case h hardware

Mac OS - software

IDLE - software

a cable - hardware

20
New cards

What is a string in Python

1 or more characters placed in a sequence is

considered to be an "ascii text" string, or just "string" for short.

21
New cards

given that that string "123.4" can be thought of as a floating point number, what do we call the process of converting that float in string form

to a binary floating point number used by the CPU to do math.

a cast or casting of the string from a string to float.

22
New cards

What is a machine language

The only language a cpu understands, it is a language created specifically for that cpu, that takes into account the register type, what the cpu is like, etc. The instructions are encoded as binary numbers so that it works well with the circuitry.

23
New cards

True/false

A variable can be thought of as a name which points to a value

True

24
New cards

Multiple choice. Given that the 8 bit

pattern 00110100 is the ascii representation for the character "4", and assuming we have a computer with only 8 bit words, what would the memory X points at look like if we executed the statement?

X = input("type in an int ")

and the user entered a 4 and then pressed enter?

a) X ---> Bad Bunny

b) X ---> 00000100

c) X ---> 00110100

c) X ---> 00110100

is right

25
New cards

What happens or can happen to a value in memory if things change and there is no variable pointing to it anymore?

it gets garbage collected

26
New cards

What is the most defining feature of "assembly" code as compared to higher level languages

It is a one to one association between a statement

of machine code and a statement in assembly.

27
New cards

What is the difference between a compiled and interpreted style of language processing?

The compiled style is to go through the whole program, converting the program to an equivalent program in another language (usually machine code). And the interpreted

style is to make no copy of the original program into another language just goes though the steps doing the actions since it can.

28
New cards

If you were editing a Python program and accidentally deleted a ":", would that cause a syntax or a logic/semantic

error?

a) syntax error is right

29
New cards

If a program asks the user for an integer, and the user responds with "dfdfdfdf" and this causes the program

to bomb, would this be a syntax or logic/semantic error?

b) logic/semantic error is right

30
New cards

What is a pointer?

A pointer, in Python, is a memory location which holds an address/name of some other memory location. This "other" location is assumed to hold something

we are interested in.

31
New cards

Suppose there are 100 students in a class, and a Python program used by the professor has a variable NumStudents, which is stored at memory location 5, and in this 5th word of memory is value 15, and at word 15 is the value 100. Then we could say NumStudents is a pointer to a value,

the value 100, which is the number of students in the class. Is this what I mean when I say a variable in Python is a pointer to a value?

a) Yes is correct

32
New cards

True or False.

In a computer program, a constant is usually something like PI, NUM_DAYS_IN_WEEK, NUM_INCHES_IN_YARD, etc., values that

make the program more English like and are unlikely to change within the program.

a) true is correct

33
New cards

Which of the following are legal variable names?:

__wwww

aaa_aaa_aaa

aaa_ee9

9ee

__wwww - yes

aaa_aaa_aaa - yes

aaa_ee9 - yes

9ee - no

34
New cards

is XXX the same variable as xxx

no. (Python is case sensitive for variables)

35
New cards

Are integer, float, string, and boolean all data types in Python?

Yes.

36
New cards

True or False:

a boolean variable takes on values "True or False"

and a string takes on values like "wwwww"

True

37
New cards

Does Python's "a variable is a pointer to a value" idea make it easier for variables to change size?

Yes

38
New cards

According to lectures, when we change the value of a variable, 1) does the interpreter accomplish this by

changing the value at the place pointed to by the variable, or 2) does the interpreter accomplish this by moving the pointer over to point to another place in memory that has the new desired value.

2nd way is correct

39
New cards

Can we change a variable's type at runtime?

Yes

40
New cards

According to lectures, are constants and variables declared the same way in Python?

yes. There is only one way to define a variable in python

41
New cards

Would you expect = or == to be used in the expression of an if statement?

a) = b) ==

b) == is correct

42
New cards

What is the output of the following code? (I suggest you do it by drawing arrows b/c you won't have idle when taking the final.)

X = 7

Y = 4

X = Y

Y = 10

print(X)

4

is printed out

43
New cards

Is __333 a legal variable name?

Yes, it is.

44
New cards

Is it true that a variable is a pointer to a value?

Yes, True.

45
New cards

Which of the following is a better representation for the following two statements of code:

X = 2

X = "aaa"

a)

X --> 2 goes to X 2

|

V

"aaa"

b)

X --> 2 goes to X --> "aaa"

a) is correct because the pointer to the value changes, not the originial value

46
New cards

How many ways are there to declare a variable in Python

as expressed in class lectures

only one

47
New cards

which of a) or b) represents the

following two statements of code:

X = 2

Y = X

a) X --> 2 goes to X --> 2 <-- Y

b) X --> 2 goes to Y --> X --> 2

a) is the correct answer

48
New cards

is it normal to execute pseudo code, yes or no

No.

49
New cards

What is a variable in Python?

A NAME OF A POINTER TO A VALUE

A pointer to a value

50
New cards

According to lectures, what happens when a variable (all of it, not a part of it) is assigned a value?

It means the new value is put into some place of memory, and then the pointer value of the variable is changed to

now point to this new place.

51
New cards

What is the output of the following code. (try to do with arrows at first, then prove with idle)

def addsTen(T):

T = T + 10

X=5

addsTen(X)

print(X)

the correct answer is 5

52
New cards

What is one advantage of Pythons indention policy over C's use of brackets to show what code belongs within an if, etc,.

The big advantage is that then both the interpreter/computer decides what code goes with what based on the same way as a human reading the program.

(in other words, humans and computer see indention in python, not just the humans as in C)

53
New cards

Describe the difference between using = and == when creating if statements.

Use == for equals within the "condition" part of an if statement;

do not use = which means "gets" within the "condition" part of an if statement (sets a value to call upon the value of the named variable)

54
New cards

Consider the code

X = 3

Y = X

X = 7

which is the correct arrow diagram for the above code

a)

X -> 3

and then

X -> 3 <- Y

and then

X ->7 Y -> 3

b)

X - > 3

and then

Y -> X -> 3

and then

X -> Y -> 3

a) is correct

55
New cards

Consider the code

X = 4

X = 5

which is the correct arrow diagram for the above code

a) X -> 4 and then X -> 5 (where the 5 replaces the 4)

b) X -> 4 and then X-> 5 (where the 4 is still in memory, at least till possibily garbage collected)

b) is correct

56
New cards

Consider the code

def fff(a):

a = 7

b = 8

fff(b)

print("aa")

which is the correct arrow diagram for the above code

a)

b from main -> 8

and then

parameter a of function fff -> 8 <- b from main

and then

b from main --> 7 <-- parameter a of function fff

and then

parameter a of function fff is gone since function fff ended

aa gets printed out

b)

b from main -> 8

and then

parameter a of function fff -> 8 <- b from main

and then

b from main --> 8 and parameter a of function fff --> 7

and then

parameter a of function fff is gone since function fff ended

aa gets printed out

b) is correct

57
New cards

what it the output of

print("aaaaa",end="");print("bbb",end="");print("c");print("d")

answer is:

aaaaabbbc

d

58
New cards

what is the output of

print(1,2,3,sep="")\

answer is

123

59
New cards

what is the output of

print(1,2,3)

answer is

1

2

3

60
New cards

Why does the following code bomb (assuming I enter a 6 at the prompt)

a=input("enter an int")

print(a+1)

official output is TypeError: can only concatenate str (not "int") to str

or you could say forgot to turn the string into an int before adding to it

61
New cards

What is the output of

b=int(5.8)

print(b)

answer is 5

62
New cards

True or False:

When doing expressions like (5 + 5.0)

the Python interpreter first turns the integer 5 into a float

True

63
New cards

Given the code

AA = []

write code with the append function

to make AA become the list with 2 elements, both equal to 2

AA = []

AA.append(2)

AA.append(2)

64
New cards

True or False?:

If I turned the following Psuedo Code into a flow chart

read in a language

if language equals Spanish

print "Badbunny says "buen día" "

else if language equals English

print "Paul McCarntney says "good day" "

else if language equals French

print "Alizee says "bonne journee" "

would I use a diamonds for the various ifs and then

a slanted parallelogram for the "read in a language"

True

65
New cards

True or False:

According to lectures, is it possible for roundoff errors to cause problems with equality with real numbers

True

66
New cards

Given the code

TheList = [2,3,4]

what would the statemet

print(TheList[2],len(TheList))

output?

The answer is

4 3

67
New cards

for int variable TEMP

write code using some or all of

these statements

"if","elif", "and", and "else"

which prints "too low"

if TEMP less than 96

prints "fine" if TEMP

is greater than or equal to 96 and less than 100

prints "fever" if TEMP

is greater than or equal to 100 and less than 103

prints "call an ambulance" if TEMP

is greater than or equal to 103

if (TEMP < 96):

print("too low")

elif (TEMP >= 96) and (TEMP <100):

print("fine")

elif (TEMP >= 100) and (TEMP <103):

print("fever")

else:

print("call an ambulance")

OR this would also do:

if (TEMP < 96):

print("too low")

elif (TEMP <100):

print("fine")

elif (TEMP <103):

print("fever")

else:

print("call an ambulance")

68
New cards

What is the output of

print("v\\n\\n\\n\\nrr\nj")

v\n\n\n\nrr

nj

69
New cards

what is the output of

print("ddddddd\nnddd")

answer

ddddddd

nddd

70
New cards

without using the append function, use an assignment

statement to create a variable aaa which is eaual to

an empty list.

answer

aaa=[]

71
New cards

Now add to aaa of question 17) the elements 1-500 using a while

loop and the append function. This is to say that

index 0 of aaa should be 1, index 1 index should be 2, etc.,

up to the 499 index which should be 500 .

Then, after this first while loop, write a second while loop

that prints what is in aaa, one element per line, so that you

get the following output:

aaa 1

aaa 2

aaa 3

. . .

aaa 500

answer

aaa=[]

i=1

while i< 501:

aaa.append(i)

i = i + 1

i=1

while i < 501:

print("aaa",aaa[i-1])

i= i+ 1

72
New cards

Given the starting code

Names =["Dan","Sally"]

Quiz1Grades=[70,56]

Quiz2Grades=[60,62]

AveGrades=[]

write two lines of code which use a for loop

and the append function to set AveGrades to a list

where for each indes, i, AveGrades[i] is

(Quiz1Grades[i] + Quiz2Grades[i])/2.0

again, use the append function to do this

answer:

for i in range(len(Quiz1Grades)):

AveGrades.append( (Quiz1Grades[i]+Quiz2Grades[i])/2)

73
New cards

Building on what you did for 19)

Now add a second for loop that prints out

Names[i],Quiz1Grades[i],Quiz2Grades[i],AveGrades[i]

all on one line, for the 2 indexes

In other words, the total code should result in

Dan 70 60 65.0

Sally 56 62 59.0

getting printed out

answer

for i in range(len(Quiz1Grades)):

print(Names[i],Quiz1Grades[i],Quiz2Grades[i],AveGrades[i])

74
New cards

Given code

astring = " James , Lamm : 12 , 19, 2021 "

write some lines of code using two "split" commands together

with the "strip", "lower" commands together with "int" casts which

assign variables

FN

LN

Month

Day

Year

MonthPlusDay

to

james

lamm

12

19

2021

31

respectively. Note that you need to convert the Month and

Day to ints in order to add them up and put the

result in variable MonthPlusDay. Also note that lower

should be used to take out the caps.

answer

astring = " James , Lamm : 12 , 19, 2021 "

name, date = astring.split(":")

FN, LN = name.split(",")

Month, Day, Year = date.split(",")

FN = FN.strip()

LN = LN.strip()

FN = FN.lower()

LN = LN.lower()

Day=int(Day)

Month=int(Month)

Year=int(Year)

MonthPlusDay=Day+Month

print(FN)

print(LN)

print(Day)

print(Month)

print(Year)

print(MonthPlusDay)

75
New cards

What does it mean that the print function is polymorphic?

It changes according to the types of things sent it.

76
New cards

when you call a function, the variables or values sent to the function are called __________.

Arguments

77
New cards

What defines an immutable variable?

the values of these variables are hard to change because they have no subpointers; their arrow pointers don't change the value pointed at, only what the argument passes as the variable

78
New cards

________ variables are declared within functions

"local" variables

79
New cards

__________ variables are declared outside of all functions

"global" variables

80
New cards

a declared variable is nonlocal when a function afunc contains another function afuncinafunc.

Is the variable nonlocal from the afuncinafunc's perspective or from the afunc's perspective?

it is nonlocal from the afuncinafunc's perspective

81
New cards

What is one thing the split command is great for doing?

Extracting/parsing data from a string that uses delimiters for separating data items

82
New cards

When using the split command can you tell Python what you want the delimiter between the strings to be?

Yes, by saying string1 = string.split(",") you can split the given string based on the commas within it

83
New cards

True/False

using lstrip, it returns the string minus blanks/invisible chars before the non-blank character.

True

Using lstrip takes only the characters after any blanks on the left/starting side to use in the string

84
New cards

True/False

using rstrip, it returns the string minus blanks/invisible chars from the end (right side) of the string

True

Useful for taking out "end of liners" or random spaces

85
New cards

Using the code string.lower() does what to the output of the string that is wanted to be printed

using lower() outputs the characters all in lowercase

86
New cards

In python, what other programming languages call "libraries" refer to the __________ of python

Modules

87
New cards

True/ False

When we call a function, we can send function names AS WELL AS variable names in our call

TRUE.

88
New cards

How does a bubble sort work in sorting a list? Does it a) go through all of the items in a list at once to reorganize them or b) go individually by adjacent items and compare them?

b) is correct

89
New cards

When does the bubble sort stop its process of sorting and swapping list items?

When it goes through the list and there are no swaps to be made, it is done.

90
New cards

Why would a variable show up as __variable__?

If you do not input the variable name, Python interpreter will name it and put the double underscore ( __ ) before and after it to say "don't mess with this"

91
New cards

A _______________ _______ is information we have stored on the computer, generally a disk / flash drive, or CD, etc.

a computer file

92
New cards

a ______ ___________ is a python type of data. It is designed by the language designed and interpreter writer to contain all data needed to open, close, change, etc a particular file on a disk or drive.

file OBJECT

93
New cards

True/False

“Opening” a file is to make a certain file on disk available to the program by means of creating a “file object” in memory that holds info necessary for reading/writing to that file. When the program is done with the file, it updates and "closes" the file with the file object going to garbage collection.

True. note the difference between the file and file object

94
New cards

What is the "closing" of a file?

Getting any remaining writes done and breaking the link between memory/program and the file on disk.

95
New cards

On a "read only" file, can you read, write, or append the file?

ONLY read from it, cannot write to it.

96
New cards

On a "write only" file, can you read, write, or append the file?

You can write to it, but cannot read from it.

97
New cards

With an "append mode" on a file, can you read, write, or append the end of the file?

With append mode, you can only add to the end of the file.

98
New cards

Yes or No.

According to lectures are Python file objects and files on disk different things?

yes, they are different.

99
New cards

Yes or No.

Does a file object get matched to a file on disk when a file is opened?

AND does a file object for a file go away when its corresponding file is closed?

Yes to both, a file object is created while working on a file, then the file is updated at closing and the file object goes to garbage.

100
New cards

Yes or No.

Is the readlines method a good way to read text files.

Yes