CNIT 155 Final Purdue University 2021

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/97

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

98 Terms

1
New cards

A computer, in some cases, understands more than machine code. T/F

False

2
New cards

Which of the following is an example of software?

A. RAM

B. Motherboard

C. WingIDE 101

D. CPU

C. WingIDE 101

3
New cards

High level programming languages include:

A. Python

B. Java

C. C

D. All of the above

D. All of the above

4
New cards

Examples of operating systems include the following, except:

A. Mac

B. Linux

C. Excel

D. Windows

C. Excel

5
New cards

_______ refers to the tangible part of a computer system.

A. Software

B. Malware

C. Memory

D. Hardware

D. Hardware

6
New cards

What piece of hardware connects all the components and devices of a computer?

A. Motherboard

B. Central Processing Unit (CPU)

C. Hard drive

D. RAM

A. Motherboard

7
New cards

A computer's "working memory" is its:

A. RAM

B. ROM

C. Flash drive

D. CPU

A. RAM

8
New cards

System software provides the real functionality of a computer, helping your computer do specific types of work. T/F

False

9
New cards

Of the options below, which equal one gigabyte?

A. 1024 Megabytes (MB)

B. 1024 Terabytes (TB)

C. 1048576 Bytes

D. 1024 Kilobytes (KB)

A. 1024 Megabytes (MB)

10
New cards

Python is commonly used to create things like websites, games, and graphic interfaces. T/F

True

11
New cards

Examples of application software include all of the following, except:

A. Microsoft Office

B. Google Chrome

C. Brightspace

D. Android

D. Android

12
New cards

Which of the following is an example of an input device?

A. Mouse

B. Speakers

C. Monitor

D. Processor

A. Mouse

13
New cards

A bit is the smallest unit of data in a computer. T/F

True

14
New cards

System software is used for __________.

A. Using the internet

B. Programming code

C. Specialized work for various operations

D. Managing a computer's resources

D. Managing a computer's resources

15
New cards

Python is considered a low-level language. T/F

False

16
New cards

What is Syntax?

A. Rules that say what the program means

B. A translator between the programming language and machine code

C. A tool to find and repair bugs

D. Rules that say what programs look like, and how the statements in the programming language are formed

D. Rules that say what programs look like, and how the statements in the programming language are formed

17
New cards

How many bytes are in a kilobyte?

A. 512

B. 8

C. 1000

D. 1024

D. 1024

18
New cards

Which of the following is not a device used to store data in a computer?

A. DVD

B. Flash Drive

C. Hard Drive

D. RAM

D. RAM

19
New cards

A string is a numerical type of data. T/F

False

20
New cards

Which of the following is an example of an integer?

A. True

B. "Hello, World!"

C. 4

D. 29.35

C. 4

21
New cards

What is the extension of the source file for a python program?

A. .python

B. .py

C. .source

D. .exe

B. .py

22
New cards

String values can never be converted to integer values. T/F

False

23
New cards

"Hello, World!" is a string T/F

True

24
New cards

Which of the following displays a proper string literal?

A. ProgrammerDialogue = 'Coding in python is fun!'

B. CNIT = I am a CIT student.

C. PurdueString = I attend Purdue University.

D. All the above

A. ProgrammerDialogue = 'Coding in python is fun!'

25
New cards

Python needs a main function to operate. T/F

False

26
New cards

Which of the following is an example of a comment in python?

A. // This is a comment in python.

B. # This is a comment in python.

C. $ This is a comment in python

D. * This is a comment in python.

B. # This is a comment in python.

27
New cards

Which of the following is an example of a boolean value?

A. "Welcome"

B. True

C. 23.546

D. 4

B. True

28
New cards

Which of the following is a legal variable name?

A. student name

B. student-name

C. 1studentname

D. studentname1

D. studentname1

29
New cards

print() is an example of an input T/F

False

30
New cards

Which of the following is true about an integer?

A. True is an integer

B. An integer is a textual data type

C. An integer can contain decimals

D. An integer can be stored as a variable

D. An integer can be stored as a variable

31
New cards

Rules of naming identifiers include the following, except:

A. Can include a space.

B. Starting with a letter or an underscore, followed by a sequence of letters, digits, and underscores.

C. The name is case sensitive.

D. The name must not be a reserved/keyword.

A. Can include a space.

32
New cards

What is the name of the python functions that tells you a class's type?

A. Type

B. Print

C. Define

D. Input

A. Type

33
New cards

Values cannot be converted from one type to another T/F

False

34
New cards

What is the value of the following expression?

9 + 3 2 * 2 / (18-16)

15

35
New cards

Which of the following operators has the highest priority in an expression?

A. +

B. /

C. ()

D. **

C. ()

36
New cards

Which is the output of the following code?

x = John

print("Hello ", x)

Hello John

37
New cards

Which of the following is a proper name for a variable?

A. True

B. StudentID

C. Class Roster

D. 1studentname

B. StudentID

38
New cards

What is the output of the following code?

Output = 11 / 2

print(int(Output))

5

39
New cards

Boolean values are case sensitive T/F

True

40
New cards

The print function does not return a value T/F

True

41
New cards

Which of the following import statements is correct to use math functions?

A. import math from *

B. import math

C. from * import math

D. from math import all

B. import math

42
New cards

The ^ operator is the same as the ** operator in Python. T/F

False

43
New cards

What is the output of the following code?

StudentIDJohn = 84219643

StudentIDEmily = 41305431

print(str(StudentIDJohn) + " " + str(StudentIDEmily))

84219643 41305431

44
New cards

Which of the following will increment the data variable by 4?

A. data %= 4

B. data += 4

C. data = 4

D. data *= 4

B. data += 4

45
New cards

7%3 is the same as 7//3. T/F

False

46
New cards

Any inputted data is considered string data, regardless of what the user inputted. T/F

True

47
New cards

Which of the following is a valid identifier in Python?

A. first-name

B. radius 3

C. vel12city

D. 1smith

C. vel12ciry

48
New cards

Which data type is 19.256?

A. integer

B. string

C. float

D. list

C. float

49
New cards

Which of the following is NOT a rule for naming an identifier?

A. The name must not be a reserved/keyword.

B. Starts with a letter, underscore, or number, followed by a sequence of letters, digits, and underscores.

C. It must not include a space.

D. The name is case sensitive.

B. Starts with a letter, underscore, or number, followed by a sequence of letters, digits, and underscores.

50
New cards

Evaluate 10 % 3.

A. 1

B. 3.33

C. 30

D. 3

A. 1

51
New cards

Which expression is written correctly?

A. 2x

B. 3(2a)

C. 3(4 + 3)

D. 5 * (7 + 4)

D. 5 * (7 + 4)

52
New cards

Which of the following is equal to n = n - 2?

A. n =- 2

B. n -= 2

C. n = -2

D. n = 2 - 2

B. n -= 2

53
New cards

The expression (2 +2 / 2 * 3) results in an integer value. T/F

False

54
New cards

Evaluate 12 + (3 ** 2)

21

55
New cards

Exponentiation has the highest priority, and is always calculated first. T/F

False

56
New cards

What is the output of the following code?

Day = 22

Month = 11

Year = 2021

print(Month, Day, Year, sep="/")

11/22/2021

57
New cards

Evaluate 20 // 3

6

(// is floor division, rounding down to the nearest whole number)

58
New cards

Evaluate 40 / (4 + 6) - 3*2

-2

59
New cards

Syntax Errors occur when a program provides you with actual outputs that are different from the desired outputs (The program runs but it gives wrong results). T/F

False

60
New cards

Assume a = 7;

b = 2;

Evaluate a // b.

3

61
New cards

Operations cannot be performed on strings. T/F

False

62
New cards

What is the term for a programming error?

A. Problem

B. Bug

C. Error

D. Syntax

B. Bug

63
New cards

Which of the following add up all the values in the list mylist and sets it to the variable total?

A. total = add(mylist)

B. total = sum(mylist)

C. total = count(mylist)

D. total = total(mylist)

B. total = sum(mylist)

64
New cards

Which of the following refer to the last element in a list names?

A. names[len(names)]

B. names[len(names)]

C. names[-0]

D. names[-1]

D. names[-1]

65
New cards

The list needs one more city added to the end - "Cario". Which piece of code below would do this?

cityList = ["Washington D.C.", "London", "Sydney", "Rio de Janeiro", "Seoul"]

A. cityList.append("Cario")

B. cityList.add("Cario")

C. cityList.push("Cario")

D. cityList.append[Cario"]

A. cityList.append("Cario")

66
New cards

Suppose list1 is [1, 3, 2], What is the result of list1 * 2?

[1, 3, 2, 1, 3, 2]

67
New cards

Which of the following would declare an empty list?

A. EmptyList = []

B. EmptyList[]

C. EmptyList = ()

D. EmptyList = ["empty"]

A. EmptyList = []

68
New cards

What output will this code produce?

color = []

color = ["blue", "green", "red"]

color.reverse()

print(color)

["red", "green", "blue"]

69
New cards

What will be the value of m[1][2] If you have the following m list:

m = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]]

8

70
New cards

In the following list, what is the value at index 1 (names[1])?

names = ['Fred', 'John', 'Sue']

John

71
New cards

Which of the following is the correct code for creating a list of names?

A. nameList = ['John', 'Harry', 'Jesse', 'John', 'Harry', 'Harry']

B. nameList = John, Harry, Jesse, John, Harry, Harry

C. nameList = ('John', 'Harry', 'Jesse', 'John', 'Harry', 'Harry')

D. nameList = [John, Harry, Jesse, John, Harry, Harry]

A. nameList = ['John', 'Harry', 'Jesse', 'John', 'Harry', 'Harry']

72
New cards

Given a tuple t = (3, 6, 2, 4), which of the following will result in errors?

A. print(t[2])

B. t[0] = 5

C. print(max(t))

D. print(len(t))

B. t[0] = 5

73
New cards

What is the output of the following code segement?

sampleList = [10, 20, 30, 40, 50]

sampleList.append(60)

print(sampleList)

sampleList.append(60)

print(sampleList)

[10, 20, 30, 40, 50, 60,]

[10, 20, 30, 40, 50, 60, 60]

74
New cards

What is the output of the following list operation?

cityList = ["Washington D.C.", "London", "Sydney", "Rio de Janeiro", "Seoul"]

print(cityList[1:3])

["London", "Sydney"]

75
New cards

Which of the following will remove the second value from the list sampleList?

A. del sampleList[2]

B. remove sampleList[2]

C. del sampleList[1]

D. remove sampleList[1]

C. del sampleList[1]

76
New cards

What is the output of the following code?

sampleList = [10, 20, 30, 40, 50]

sampleList[-2] = 20

print(sampleList)

[10, 20, 30, 20, 50]

77
New cards

What is the output of the following print statement?

sampleList = [10, 20, 30, 40, 50, 60]

print(sampleList[-2])

50

78
New cards

Which of the following options will correctly add the elements of ListTwo to ListOne in Python.

ListOne = ["a", "b", "c", "d"]

ListTwo = ["e", "f", "g"]

A. ListOne = ListOne.extend(ListTwo)

B. ListOne.add(ListTwo)

C. ListOne = ListOne +ListTwo

D. ListOne + ListTwo

C. ListOne = ListOne +ListTwo

79
New cards

Which output will the following code produce?

color = []

color = ["blue", "green", "red"]

print(color[2])

red

80
New cards

Which of the following will randomize the order of elements in a list sampleList? Assume that the required library has been imported correctly.

A. sort(sampleList)

B. shuffle(sampleList)

C. random(sampleList)

D. randomize(sampleList)

B. shuffle(sampleList)

81
New cards

list1 = [1, 2, 3, 4]

list2 = [5, 6, 7, 8]

print ( len(list1 + list2) )

8

82
New cards

Passing a list as an argument passes a copy of the list. T/F

False

83
New cards

Lists are mutable T/F

True

84
New cards

The built-in function split() return a list T/F

True

85
New cards

The index of the first value in a python list is 1 T/F

False

86
New cards

Lists are a type of data structure that can store many values under one name T/F

True

87
New cards

Analyze the following code:

count = 0

while count < 100:

#Point A

print("Welcome to Python!")

count += 1

#Point B

#Point C

A. count < 100 is always True at point c

B. count < 100 is always True at point b

C. All answers are False

D. count < 100 is always True at point A

B. count < 100 is always True at point b

<p>B. count &lt; 100 is always True at point b</p>
88
New cards

While loops are pretest loops T/F

True

89
New cards

In Python, the division operator (/) gives a float result, even if both of the numbers are integers T/F

False

90
New cards

What is the output of the following code?

n = 20

while (n <= 25):

print(n,"\n")

n = n+1

20,21,22,23,24,25

91
New cards

If we want score to be a random number in the range of [10.0, 50.0), which statement would be correct (assuming the random library has been imported)?

A. score = 40.0 * random + 10.0

B. score = 50.0 * random + 10.0

C. score = 10.0 * random + 40.0

D. score = random() + 50.0

A. score = 40.0 * random + 10.0

92
New cards

The expression 3 ** 3 - (6-2)/2 has the value _____. Is it an integer or a float value? __________________.

A. 7, int

B. 25, float

C. 7, float

D. 25, int

B. 25, float

93
New cards

Suppose you're given a list of words, intList. Write Python code that will print one line for each number, repeating that number twice. For example, if intList is [60, 70, 80, 90], then your code would print:

60 60

70 70

80 80

90 90

def main():

intList = [60, 70, 80, 90]

for i in range(0, len(intList)):

print(intList[i], " ", intList[i], "\n")

i += 1

main()

94
New cards

Write a Python program to check if the letter 'e' is in a given string:

Example:

Enter a string: play

The letter e is not exist in the string.

Enter a string: Umbrella

The letter e is exist in the string.

def main():

userinput = input("Enter a string: ")

userinputupper = userinput.upper()

numE = userinputupper.count("E")

if numE > 0:

print("The letter e is exist in the string.")

else:

print("The letter e is not exist in the string.")

main()

95
New cards

Write a Python program that requests an integer from the user. If the value is between 1 and 100 inclusive, print "OK". Otherwise, do not print anything.

96
New cards

The input function returns a boolean if the user types in True. T/F

True

97
New cards

Strings can be used as a sequence in a for loop. T/F

True

98
New cards

Which of the following range function syntax is incorrect?

A. range(0, 3, 5)

B. range(10, 4, -1)

C. range(1, 3, 1)

D. range(1, 2.5, 4.5)

D. range(1, 2.5, 4.5)