# Its320 mod 3 mastery ex attempt 2

Content type
User Generated
Rating
Showing Page:
1/5
Score for this attempt: 9 out of 10
Submitted Jan 18 at 12:27pm
This attempt took 7 minutes.
Question 1
1 / 1 pts
What is the console output of the following Python statement: print(3 and 5) ?
True
3
8
5
Correct! “3 and 5” is short-circuited. Since “3” evaluates to “True”, then the second part
of the “and” statement is evaluated which is “5.” Since “5” is “True,” the output will be
“5.”
Question 2
1 / 1 pts
Let set a = set([1,2,3]) and set b = set([-1,-2,-3]). What is a | b?
set([])
set([0,0,0])
set([1,2,3])
set([1,2,3,-1,-2,-3])

Showing Page:
2/5
Correct! The “|” operator produces a set that contains the distinct elements from both
sets. The new set does not have any duplicate elements.
Question 3
1 / 1 pts
Let set a = set([1,2,3]) and set b = set([-1,-2,-3]). What is a & b?
set([])
set([0,0,0])
set([1,2,3])
set([1,2,3,-1,-2,-3])
Correct! The “&” operator produces a set that contains the distinct elements that is
common to both sets.
Question 4
1 / 1 pts
Given the following code snippet, what is the output?
def fun(i):
print "executed"
return i
def main():
print (1 or fun(1)) # due to short-circuiting, "executed" not printed
True
1
executed

Showing Page:
3/5

End of Preview - Want to read all 5 pages?
Access Now
Unformatted Attachment Preview
Score for this attempt: 9 out of 10 Submitted Jan 18 at 12:27pm This attempt took 7 minutes. Question 1 1 / 1 pts What is the console output of the following Python statement: print(3 and 5) ? True 3 8 5 Correct! “3 and 5” is short-circuited. Since “3” evaluates to “True”, then the second part of the “and” statement is evaluated which is “5.” Since “5” is “True,” the output will be “5.” Question 2 1 / 1 pts Let set a = set([1,2,3]) and set b = set([-1,-2,-3]). What is a | b? set([]) set([0,0,0]) set([1,2,3]) set([1,2,3,-1,-2,-3]) Correct! The “|” operator produces a set that contains the distinct elements from both sets. The new set does not have any duplicate elements. Question 3 1 / 1 pts Let set a = set([1,2,3]) and set b = set([-1,-2,-3]). What is a & b? set([]) set([0,0,0]) set([1,2,3]) set([1,2,3,-1,-2,-3]) Correct! The “&” operator produces a set that contains the distinct elements that is common to both sets. Question 4 1 / 1 pts Given the following code snippet, what is the output? def fun(i): print "executed" return i def main(): print (1 or fun(1)) # due to short-circuiting, "executed" not printed True 1 executed The code throws an error Correct! The “or” statement inside the print statement is short-circuited; that is, since “1” is true, then the other half of the “or” statement is not executed. Question 5 1 / 1 pts Let list a = [1,2,3] and list b = [-1,-2,-3]. What is a + b? [0,0,0] [] [1,2 ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

### Review

Anonymous
Great! Studypool always delivers quality work.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4