What is a Python variable?
A variable is a name bound to a value. The same name can later refer to a value of a different type.
Study 1 Programming Foundations for Data Science with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
What is a Python variable?
A variable is a name bound to a value. The same name can later refer to a value of a different type.
What does a value’s data type determine?
A value’s data type determines which operations make sense for it.
What characterizes a Python list?
A list is an ordered, changeable sequence, suitable for values that may be added, removed, or updated.
What distinguishes a tuple from a list?
A tuple is an ordered sequence that cannot be changed after creation.
What is a Python dictionary useful for representing?
A dictionary is a changeable mapping from keys to values, useful for representing records with named fields.
What is a key property of a Python set?
A set stores distinct values and is useful for membership checks or removing duplicates. It has no positional indexing.
At what index does a Python list or tuple begin?
Lists and tuples use positions starting at index 0, so the first element is accessed at index 0.
How do you check a collection’s size and membership?
Use len(collection) to get its size and value in collection to test whether it contains a value.
How do if, elif, and else divide conditional logic?
if tests the first condition, elif checks another if earlier tests were false, and else handles the remaining case.
Why use is None instead of a general truth test?
Use is None to check specifically for None. Empty collections and zero are also false in conditions, but are not None.
When is a for loop useful?
A for loop visits each item in an iterable, such as a list or dictionary.
What keeps a while loop repeating?
A while loop repeats as long as its condition remains true. Make sure the condition can eventually become false to avoid an endless loop.