Python 1 2 Flashcards
(38 cards)
What does one row represent in a tabular dataset?
a single item/observation in your collection
What does one column represent in a tabular dataset?
a single piece of information
What shape does tabular data take?
a rectangle
What’s the difference between = and == in Python?
= assigns a value to a variable, == tests whether two items are the same
How do you write a multi-line string in Python?
””” wrap it in three quotes “””
How do you write a comment in Python?
#
What are the rules for Python variable names?
can use any upper/lowercase character, number, or _
What is the function to check what Python type something is?
type
How would you make a string with ‘my qb is Tom Brady’ using f strings if ‘Tom Brady’ was in a variable called name?
f’my qb is {name}’
(Python) What type of a variable is (1 == 2)?
bool
(Python) What is the value of (1 == 2)?
FALSE
(Python) What is the difference between variables and strings in terms of quotation marks?
strings always have quotation marks; variables never do
(Python) How would you refer to the first element in a list named my_list?
my_list[0]
(Python) How would you refer to the last element in a list named my_list?
my_list[-1]
(Python) How would you refer to the first two elements in a list named my_list?
my_list[0:2]
(Python) What is the name for the part in brackets in my_list[0:2]?
a slice
(Python) How many items does my_list[:n] return?
n
(Python) What is a list surrounded by?
square brackets
What is a Python dict?
a collection of key, value pairs
(Python) What is a dict surrounded by?
curly brackets
(Python) How would you access 1 in my_dict = {‘a’: 1, ‘b’: 2}?
my_dict[‘a’]
(Python) How would you change ‘a’ to 0 in my_dict = {‘a’: 1, ‘b’: 2}?
my_dict[‘a’] = 0
(Python) How would you add a new item ‘c’ = 3 in my_dict = {‘a’: 1, ‘b’: 2}?
my_dict[‘c’] = 3
What is a loop in Python?
a way to do something for every item in a collection