Which of the following is the most appropriate documentation to appear with the printnums procedure?

Firstly, I think part of your confusion is what exactly "variable" means. In Python it's not the best terminology because Python really has names (or identifiers), and values (or objects). Names point to values. For more on that, see Facts and myths about Python names and values by Ned Batchelder.

Secondly, another part of your confusion might be the difference between mutable and immutable types. Strings are immutable, but lists are mutable. Therefore strings can't have methods that mutate them, but lists can. (And for that matter, other functions can mutate them, e.g. random.shuffle(nums).) For more on that, this answer is a good intro.

Now, even with that out of the way, there's still some ambiguity, but the function documentation will almost always tell you. And if it helps, the difference here is between procedures, which are used for their side-effects*, and functions proper, which are used to return a value. See What is the difference between a "function" and a "procedure"? But these are just concepts; the reality is a grey area; for example the file method write() is primarily used to write to the file, but it also returns the number of characters written.

Related concepts:

  • In-place algorithm
    • How to know if a command or method is an 'in place algorithm'?
  • Pure function
    • What are non-pure functions in python?

* Sidenote: "Mutator method" would seem like a natural fit, but that has a more specific definition in the context of OOP.

Two lists, list1 and list2, contain the names of books found in two different collections. A librarian wants to create newList, which will contain the names of all books found in either list, in alphabetical order, with duplicate entries removed.
For example, if list1 contains
["Macbeth", "Frankenstein", "Jane Eyre"]
and list2 contains
["Frankenstein", "Dracula", "Macbeth", "Hamlet"],
then newList will contain
["Dracula", "Frankenstein", "Hamlet", "Jane Eyre", "Macbeth"].
The following procedures are available to create newList. Which of the following code segments will correctly create newList ?

For which of the following lists can a binary search be used to search for an item in the list?
["blue", "green", "jade", "mauve", "pink"]
[5, 5, 5, 5, 6, 7, 8, 8, 8]
[10, 5, 3, 2, -4, -8, -9, -12]

Sets found in the same folder

Suppose a large group of people in a room were all born in the same year. Consider the following three algorithms, which are each intended to identify the people in the room who have the earliest birthday based on just the month and day. For example, a person born on February 10 is considered to have an earlier birthday than a person born on March 5. Which of the three algorithms will identify the correct people?
I. All the people in the room stand up. All standing people form pairs where possible, leaving at most one person not part of a pair. For each pair, the person with the earlier birthday remains standing, while the other person in the pair sits down. If there is a tie, both people sit down. Any individual not part of a pair remains standing. Continue doing this until only one person remains standing. That person has the earliest birthday.
II. All the people in the room stand up. All standing people form pairs with another standing person that they have not previously been paired with where possible, leaving at most one person not part of a pair. For each pair, the person with the earlier birthday remains standing, while the other person in the pair sits down. If there is a tie, both people in the pair remain standing. Any individual not part of a pair remains standing. Continue doing this until only one person remains standing or all persons standing have the same birthday. Anyone still standing has the earliest birthday.
III. Beginning with the number 1, ask if anyone was born on that day of any month. Continue with the numbers 2, 3, and so on until a positive response is received. If only one person responds, that person has the earliest birthday. If more than one person responds, determine which person was born in the earliest month, and that person or those persons have the earliest birthday.

Sets with similar terms

What is the most appropriate data type for age?

So, we should use integer data type for age.

Which of the following best explains the benefit of using a list as a data abstraction in this situation?

Which of the following best explains the benefit of using a list as a data abstraction in this situation? Keeping the numeric values in a list makes it easier to apply the same computation to every data element.

Which of the following best describes the behavior of how pairs of elements are compared?

Which of the following best describes the behavior of how pairs of elements are compared? The code segment iterates through myList, comparing each element to all subsequent elements in the list.

What are two advantages of using well named variables?

Which of the following are benefits of well-named variables? -The program will be easier to read. -The program will be easier for others to debug.