Docsity

INTRODUCTION TO PYTHON PROGRAMMING AND DATA STRUCTURES COMPREHENSIVE EXAMINATION TEST COMP, Exams of Object Oriented Programming

Toggle sidebar
bg1
INTRODUCTION TO PYTHON
PROGRAMMING AND DATA STRUCTURES
COMPREHENSIVE EXAMINATION TEST
COMPLETE QUESTIONS AND CORRECT
ANSWERS
●● The first line of a function definition is known as the .
1. body
2. introduction
3. initialization
4. header
Answer: D
●● You ____ a function to execute it.
1. define
2. call
3. import
4. export
Answer: B
●● A ____ is a variable that is created inside a function.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25

Partial preview of the text

Download INTRODUCTION TO PYTHON PROGRAMMING AND DATA STRUCTURES COMPREHENSIVE EXAMINATION TEST COMP and more Exams Object Oriented Programming in PDF only on Docsity!

INTRODUCTION TO PYTHON

PROGRAMMING AND DATA STRUCTURES

COMPREHENSIVE EXAMINATION TEST

COMPLETE QUESTIONS AND CORRECT

ANSWERS

●● The first line of a function definition is known as the.

  1. body
  2. introduction
  3. initialization
  4. header Answer: D ●● You ____ a function to execute it.
  5. define
  6. call
  7. import
  8. export Answer: B ●● A ____ is a variable that is created inside a function.
  1. global variable
  2. local variable
  3. hidden variable
  4. none of the above; you cannot create a variable inside a function Answer: B ●● A(n) _____ is the part of a program in which a variable may be accessed.
  5. declaration space
  6. area of visibility
  7. scope
  8. mode Answer: C ●● A(n) _____ is a piece of data that is sent into a function.
  9. argument
  10. parameter
  11. header
  12. packet Answer: A ●● A(n) ____ is a special variable that receives a piece of data when a function is called.
  1. standard function
  2. library function
  3. custom function
  4. cafeteria function Answer: B ●● This standard library function returns a random integer within a specified range of values.
  5. random
  6. randint
  7. random_integer
  8. uniform Answer: B ●● This statement causes a function to end and sends a value back to the part of the program that called the function.
  9. end
  10. send
  11. exit
  12. return Answer: D

●● This type of function returns either True or False.

  1. Binary
  2. true_false
  3. Boolean
  4. logical Answer: C ●● Calling a function and defining a function mean the same thing. Answer: F ●● A statement in one function can access a local variable in another function. Answer: F ●● In Python, you cannot write functions that accept multiple arguments. Answer: F ●● Some library functions are built into the Python interpreter. Answer: T ●● You do not need to have an import statement in a program to use the functions in the random
  1. encrypted
  2. closed
  3. opened Answer: D ●● When a program is finished using a file, it should do this.
  4. erase the file
  5. open the file
  6. close the file
  7. encrypt the file Answer: C ●● The contents of this type of file can be viewed in an editor such as Notepad.
  8. text file
  9. binary file
  10. English file Answer: A ●● When an exception is generated, it is said to have been.
  11. built
  12. raised
  1. caught
  2. killed Answer: B ●● This is a section of code that gracefully responds to exceptions.
  3. exception generator
  4. exception manipulator
  5. exception handler
  6. exception monitor Answer: C ●● You write this statement to respond to exceptions.
  7. run/handle
  8. try/except
  9. try/handle
  10. attempt/except Answer: B ●● When you open a file that file already exists on the disk using the 'w' mode, the contents of the existing file will be erased. Answer: T

●● This term refers to an individual item in a list.

  1. element
  2. bin
  3. cubbyhole
  4. slot Answer: A ●● This is a number that identifies an item in a list.
  5. element
  6. index
  7. bookmark
  8. identifier Answer: B ●● This is the first index in a list.
  9. −
  10. 1
  11. 0
  12. The size of the list minus one Answer: C

●● This is the last index in a list.

  1. 1
  2. 99
  3. 0
  4. The size of the list minus one Answer: D ●● This will happen if you try to use an index that is out of range for a list.
  5. A ValueError exception will occur.
  6. An IndexError exception will occur.
  7. The list will be erased and the program will continue to run. 479
  8. Nothing—the invalid index will be ignored. Answer: B ●● This function returns the length of a list.
  9. length
  10. size
  11. len
  12. lengthof Answer: C

●● Which of the following statements creates a tuple?

  1. values = [1, 2, 3, 4]
  2. values = {1, 2, 3, 4}
  3. values = (1)
  4. values = (1,) Answer: D ●● Lists in Python are immutable. Answer: F ●● Tuples in Python are immutable. Answer: T ●● A file object's writelines method automatically writes a newline ('\n') after writing each list item to the file. Answer: F ●● You can use the + operator to concatenate two lists. Answer: T

●● A list can be an element in another list. Answer: T ●● You can remove an element from a tuple by calling the tuple's remove method. Answer: F ●● This is the first index in a string.

  1. −
  2. 1
  3. 0
  4. The size of the string minus one Answer: C ●● This is the last index in a string.
  5. 1
  6. 99
  7. 0
  8. The size of the string minus one Answer: D ●● This string method returns a copy of the string with all leading and trailing whitespace
  1. logic
  2. fatal Answer: C ●● A____ is a sequence of characters.
  3. char sequence
  4. character collection
  5. string
  6. text block Answer: C ●● A ____ is a name that references a value in the computer's memory.
  7. variable
  8. register
  9. RAM slot
  10. byte Answer: A ●● A string literal in Python must be enclosed in.
  11. parentheses.
  12. single-quotes.
  13. double-quotes.
  1. either single-quotes or double-quotes. Answer: D ●● Short notes placed in different parts of a program explaining how those parts of the program work are called.
  2. comments
  3. reference manuals
  4. tutorials
  5. external documentation Answer: A ●● A(n) _____ makes a variable reference a value in the computer's memory.
  6. variable declaration
  7. assignment statement
  8. math expression
  9. string literal Answer: B ●● This symbol marks the beginning of a comment in Python.
  10. &

Answer: A ●● This is an operator that raises a number to a power.

  1. %
  2. **
  3. / Answer: C ●● This operator performs division, but instead of returning the quotient it returns the remainder.
  4. %
  5. **
  6. / Answer: A ●● Suppose the following statement is in a program: price = 99.0. After this statement executes, the price variable will reference a value of which data type?
  7. int
  1. float
  2. currency
  3. str Answer: B ●● Which built-in function can be used to read input that has been typed on the keyboard?
  4. input()
  5. get_input()
  6. read_input()
  7. keyboard() Answer: A ●● Which built-in function can be used to convert an int value to a float?
  8. int_to_float()
  9. float()
  10. convert()
  11. int() Answer: B ●● A magic number is.
  12. a number that is mathematically undefined