Arrange the following mathematical operators in the correct order of operations
according to python. 1 is the first and 4 is the last.
%, +, (), **
Give this one a try later!
() ** % +
nums = [1, 1, 2, 3, 5, 8, 13]
What is the result of nums[1:5]?
Give this one a try later!
[1, 2, 3, 5]
,nums = [1, 1, 2, 3, 5, 8, 13]
What is the result of nums[3:1]?
Give this one a try later!
[] (can't go backwards)
Let Address = namedtuple('Address', ['street', 'city', 'country']). Create a new address
object house where house.street is "221B Baker Street", house.city is "London", and
house.country is "England".
Give this one a try later!
house = Address('221B Baker Street', 'London', 'England')
What type of error does the following code produce?
x=4
y = timestwo(x)
def timestwo(x):
return x * 2
print(y)
Give this one a try later!
NameError
,Write the simplest two statements that first sort my_list, then remove the largest value
element from the list, using list methods.
Give this one a try later!
my_list.sort()
my_list.pop()
Write an expression that concatenates the list feb_temps to the end of jan_temps.
Give this one a try later!
jan_temps + feb_temps
What is a ZeroDivisionError exception type?
Give this one a try later!
Divide by zero error
Create a new named tuple Dog that has the attributes name, breed, and color.
Give this one a try later!
Dog = namedtuple('Dog', ['name', 'breed', 'color'])
, What does all(my_list) provide?
Give this one a try later!
If the list contains a 0 element, all() returns False because not all elements
are non-zero, else returns True
Which expression checks if the value 10 exists in the dictionary my_dict?
Give this one a try later!
None of the above. The in operator only checks the keys of a dict, not the
values.
How do you sort my_list from highest to lowest and then print the reversed list?
Give this one a try later!
for i in reversed(sorted(my_list)):
print(i)
Write the simplest expression that captures the desired comparison.
The character 'G' exists in the string my_str.
Give this one a try later!
according to python. 1 is the first and 4 is the last.
%, +, (), **
Give this one a try later!
() ** % +
nums = [1, 1, 2, 3, 5, 8, 13]
What is the result of nums[1:5]?
Give this one a try later!
[1, 2, 3, 5]
,nums = [1, 1, 2, 3, 5, 8, 13]
What is the result of nums[3:1]?
Give this one a try later!
[] (can't go backwards)
Let Address = namedtuple('Address', ['street', 'city', 'country']). Create a new address
object house where house.street is "221B Baker Street", house.city is "London", and
house.country is "England".
Give this one a try later!
house = Address('221B Baker Street', 'London', 'England')
What type of error does the following code produce?
x=4
y = timestwo(x)
def timestwo(x):
return x * 2
print(y)
Give this one a try later!
NameError
,Write the simplest two statements that first sort my_list, then remove the largest value
element from the list, using list methods.
Give this one a try later!
my_list.sort()
my_list.pop()
Write an expression that concatenates the list feb_temps to the end of jan_temps.
Give this one a try later!
jan_temps + feb_temps
What is a ZeroDivisionError exception type?
Give this one a try later!
Divide by zero error
Create a new named tuple Dog that has the attributes name, breed, and color.
Give this one a try later!
Dog = namedtuple('Dog', ['name', 'breed', 'color'])
, What does all(my_list) provide?
Give this one a try later!
If the list contains a 0 element, all() returns False because not all elements
are non-zero, else returns True
Which expression checks if the value 10 exists in the dictionary my_dict?
Give this one a try later!
None of the above. The in operator only checks the keys of a dict, not the
values.
How do you sort my_list from highest to lowest and then print the reversed list?
Give this one a try later!
for i in reversed(sorted(my_list)):
print(i)
Write the simplest expression that captures the desired comparison.
The character 'G' exists in the string my_str.
Give this one a try later!