What is a Python variable, and what does = do?
A variable is a name associated with a value; Python’s = assigns a value to a name rather than testing mathematical equality.
Study 2 Programming Foundations for Data Analysis with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
What is a Python variable, and what does = do?
A variable is a name associated with a value; Python’s = assigns a value to a name rather than testing mathematical equality.
When does Python determine a value’s type?
Python determines a value’s type at runtime. Converting numeric text with float(), for example, can make it usable as a decimal number.
What is a Python list suited for?
A list is an ordered, changeable sequence, useful for storing observations or measurements.
How do if, elif, and else divide conditional cases?
Use if for the first test, elif for additional possibilities, and else for the remaining case. Each controls its indented block.
How does a for loop process a collection?
A for loop processes items in a collection in turn; its loop variable takes the next item on each pass.
What are the roles of def, parameters, and return in a function?
A function is a named, reusable block of code. Define it with def, use parameters for inputs, and return to send a result to the caller.
How does a tuple differ from a list?
A tuple is an ordered, unchangeable sequence, useful for a fixed group of related values.
How can a dictionary safely handle a possibly missing key?
A dictionary stores key–value pairs. Its get() method can return a default value when a key is absent, avoiding a KeyError.
When is a set useful?
A set stores distinct values, making it useful when duplicates are not needed.
What index refers to the first item in a Python list?
Python list indexes start at zero, so readings[0] refers to the first item.
Which Python operators combine or reverse logical tests?
Use and, or, and not to combine or reverse logical tests in a condition.
When does a while loop repeat?
A while loop repeats its code as long as its condition remains true.