Docsity

Introduction to Python Programming Essential Revision Q&A – 2026–2027 Edition, Exams of Programming Languages

Toggle sidebar
bg1
Introduction to Python Programming Essential
Revision Q&A – 2026–2027 Edition
A design technique that helps to reduce the duplication of code within a
program and is a
benefit of using functions is .
1. code reuse
2. divide and conquer
3. debugging
4. facilitation of teamwork - Correct Answers ✅A
The first line of a function definition is known as the .
1. body
2. introduction
3. initialization
4. header - Correct Answers ✅D
You ____ a function to execute it.
1. define
2. call
3. import
4. export - Correct Answers ✅B
A ____ is a variable that is created inside a function.
1. global variable
2. local variable
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e

Partial preview of the text

Download Introduction to Python Programming Essential Revision Q&A – 2026–2027 Edition and more Exams Programming Languages in PDF only on Docsity!

Revision Q&A – 2026–2027 Edition

A design technique that helps to reduce the duplication of code within a program and is a benefit of using functions is.

  1. code reuse
  2. divide and conquer
  3. debugging
  4. facilitation of teamwork - Correct Answers ✅A The first line of a function definition is known as the.
  5. body
  6. introduction
  7. initialization
  8. header - Correct Answers ✅D You ____ a function to execute it.
  9. define
  10. call
  11. import
  12. export - Correct Answers ✅B A ____ is a variable that is created inside a function.
  13. global variable
  14. local variable

Revision Q&A – 2026–2027 Edition

  1. hidden variable
  2. none of the above; you cannot create a variable inside a function - Correct Answers ✅B A(n) _____ is the part of a program in which a variable may be accessed.
  3. declaration space
  4. area of visibility
  5. scope
  6. mode - Correct Answers ✅C A(n) _____ is a piece of data that is sent into a function.
  7. argument
  8. parameter
  9. header
  10. packet - Correct Answers ✅A A(n) ____ is a special variable that receives a piece of data when a function is called.
  11. argument
  12. parameter
  13. header
  14. packet - Correct Answers ✅B

Revision Q&A – 2026–2027 Edition

  1. uniform - Correct Answers ✅B This statement causes a function to end and sends a value back to the part of the program that called the function.
  2. end
  3. send
  4. exit
  5. return - Correct Answers ✅D This type of function returns either True or False.
  6. Binary
  7. true_false
  8. Boolean
  9. logical - Correct Answers ✅C Calling a function and defining a function mean the same thing. - Correct Answers ✅F A statement in one function can access a local variable in another function. - Correct Answers ✅F In Python, you cannot write functions that accept multiple arguments. - Correct Answers ✅F

Revision Q&A – 2026–2027 Edition

Some library functions are built into the Python interpreter. - Correct Answers ✅T You do not need to have an import statement in a program to use the functions in the random module. - Correct Answers ✅F A function in Python can return more than one value. - Correct Answers ✅T A file that data is written to is known as a(n).

  1. input file
  2. output file
  3. sequential access file
  4. binary file - Correct Answers ✅B A file that data is read from is known as a(n).
  5. input file
  6. output file
  7. sequential access file
  8. binary file - Correct Answers ✅A Before a file can be used by a program, it must be.

Revision Q&A – 2026–2027 Edition

This is a section of code that gracefully responds to exceptions.

  1. exception generator
  2. exception manipulator
  3. exception handler
  4. exception monitor - Correct Answers ✅C You write this statement to respond to exceptions.
  5. run/handle
  6. try/except
  7. try/handle
  8. attempt/except - Correct Answers ✅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. - Correct Answers ✅T The process of opening a file is only necessary with input files. Output files are automatically opened when data is written to them. - Correct Answers ✅F If you do not handle an exception, it is ignored by the Python interpreter, and the program continues to execute. - Correct Answers ✅F

Revision Q&A – 2026–2027 Edition

You can have more than one except clause in a try/except statement. - Correct Answers ✅T The else suite in a try/except statement executes only if a statement in the try suite raises an exception. - Correct Answers ✅F The finally suite in a try/except statement executes only if no exceptions are raised by statements in the try suite. - Correct Answers ✅F This term refers to an individual item in a list.

  1. element
  2. bin
  3. cubbyhole
  4. slot - Correct Answers ✅A This is a number that identifies an item in a list.
  5. element
  6. index
  7. bookmark
  8. identifier - Correct Answers ✅B

Revision Q&A – 2026–2027 Edition

  1. len
  2. lengthof - Correct Answers ✅C This list method adds an item to the end of an existing list.
  3. add
  4. add_to
  5. increase
  6. append - Correct Answers ✅D If you call the index method to locate an item in a list and the item is not found, this happens.
  7. A ValueError exception is raised.
  8. An InvalidIndex exception is raised.
  9. The method returns −1.
  10. Nothing happens. The program continues running at the next statement. - Correct Answers ✅A This file object method returns a list containing the file's contents.
  11. to_list
  12. getlist
  13. readline
  14. readlines - Correct Answers ✅D

Revision Q&A – 2026–2027 Edition

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,) - Correct Answers ✅D Lists in Python are immutable. - Correct Answers ✅F Tuples in Python are immutable. - Correct Answers ✅T A file object's writelines method automatically writes a newline ('\n') after writing each list item to the file. - Correct Answers ✅F You can use the + operator to concatenate two lists. - Correct Answers ✅T A list can be an element in another list. - Correct Answers ✅T You can remove an element from a tuple by calling the tuple's remove method. - Correct Answers ✅F This is the first index in a string.
  5. −

Revision Q&A – 2026–2027 Edition

When you call a string's split method, the method divides the string into two substrings. - Correct Answers ✅F A ___ error does not prevent the program from running, but causes it to produce incorrect results.

  1. syntax
  2. hardware
  3. logic
  4. fatal - Correct Answers ✅C A____ is a sequence of characters.
  5. char sequence
  6. character collection
  7. string
  8. text block - Correct Answers ✅C A ____ is a name that references a value in the computer's memory.
  9. variable
  10. register
  11. RAM slot
  12. byte - Correct Answers ✅A

Revision Q&A – 2026–2027 Edition

A string literal in Python must be enclosed in.

  1. parentheses.
  2. single-quotes.
  3. double-quotes.
  4. either single-quotes or double-quotes. - Correct Answers ✅D Short notes placed in different parts of a program explaining how those parts of the program work are called.
  5. comments
  6. reference manuals
  7. tutorials
  8. external documentation - Correct Answers ✅A A(n) _____ makes a variable reference a value in the computer's memory.
  9. variable declaration
  10. assignment statement
  11. math expression
  12. string literal - Correct Answers ✅B This symbol marks the beginning of a comment in Python.
  13. &

Revision Q&A – 2026–2027 Edition

  1. / - Correct Answers ✅C This operator performs division, but instead of returning the quotient it returns the remainder.
  2. %
  3. **
  4. / - Correct Answers ✅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?
  5. int
  6. float
  7. currency
  8. str - Correct Answers ✅B Which built-in function can be used to read input that has been typed on the keyboard?
  9. input()

Revision Q&A – 2026–2027 Edition

  1. get_input()
  2. read_input()
  3. keyboard() - Correct Answers ✅A Which built-in function can be used to convert an int value to a float?
  4. int_to_float()
  5. float()
  6. convert()
  7. int() - Correct Answers ✅B A magic number is.
  8. a number that is mathematically undefined
  9. an unexplained value that appears in a program's code
  10. a number that cannot be divided by 1
  11. a number that causes computers to crash - Correct Answers ✅B A is a name that represents a value that does not change during the program's execution.
  12. named literal
  13. named constant
  14. variable signature
  15. key term - Correct Answers ✅B

Revision Q&A – 2026–2027 Edition

  1. single alternative decision
  2. one path alternative
  3. single execution decision - Correct Answers ✅B A(n) ____ expression has a value of either True or False.
  4. binary
  5. decision
  6. unconditional
  7. Boolean - Correct Answers ✅D The symbols >, <, and == are all operators.
  8. relational
  9. logical
  10. conditional
  11. ternary - Correct Answers ✅A A(n) structure tests a condition and then takes one path if the condition is true, or another path if the condition is false.
  12. if statement
  13. single alternative decision 211
  14. dual alternative decision

Revision Q&A – 2026–2027 Edition

  1. sequence - Correct Answers ✅C and, or, and not are operators.
  2. relational
  3. logical
  4. conditional
  5. ternary - Correct Answers ✅C A compound Boolean expression created with the ____ operator is true if either of its subexpressions is true.
  6. and
  7. or
  8. not
  9. either - Correct Answers ✅B You can write any program using only sequence structures - Correct Answers ✅F A program can be made of only one type of control structure. You cannot combine structures - Correct Answers ✅F A single alternative decision structure tests a condition and then takes one path if the condition