Question
Given two numbers represented as strings, return multiplication of the numbers as a string. Note: The numbers can be arbitrarily large and are non-negative. Note2:
Given two numbers represented as strings, return multiplication of the numbers as a string.
Note: The numbers can be arbitrarily large and are non-negative.
Note2: Your answer should not have leading zeroes. For example, 00 is not a valid answer.
For example,
given strings "12", "10", your answer should be "120".
Please note that python code for above question should pass large test cases, and all corner test cases, reasoning for below MCQs is also needed, please dont copy (unhelpful if copied or didn't answer all)
1. What will be the output of the following Python code?
s1={3, 4}
s2={1, 2}
s3=set()
i=0
j=0
for i in s1:
for j in s2:
s3.add((i,j))
i+=1
j+=1
print(s3)
a) {(3, 4), (1, 2)}
b) Error
c) {(4, 2), (3, 1), (4, 1), (5, 2)}
d) {(3, 1), (4, 2)}
2. The ____ function removes the first element of a set and the last element of a list.
a) remove
b) pop
c) discard
d) dispose
3. The difference between the functions discard and remove is that:
a) Discard removes the last element of the set whereas remove removes the first element of the set
b) Discard throws an error if the specified element is not present in the set whereas remove does not throw an error in case of absence of the specified element
c) Remove removes the last element of the set whereas discard removes the first element of the set
d) Remove throws an error if the specified element is not present in the set whereas discard does not throw an error in case of absence of the specified element
4. What will be the output of the following Python code?
s1={1, 2, 3}
s2={3, 4, 5, 6}
s1.difference(s2)
s2.difference(s1)
a)
{1, 2}
{4, 5, 6}
b)
{1, 2}
{1, 2}
c)
{4, 5, 6}
{1, 2}
d)
{4, 5, 6}
{4, 5, 6}
5. What will be the output of the following Python code?
s1={1, 2, 3}
s2={4, 5, 6}
s1.isdisjoint(s2)
s2.isdisjoint(s1)
a)
True
False
b)
False
True
c)
True
True
d)
False
False
6. If we have two sets, s1 and s2, and we want to check if all the elements of s1 are present in s2 or not, we can use the function:
a) s2.issubset(s1)
b) s2.issuperset(s1)
c) s1.issuperset(s2)
d) s1.isset(s2)
7. What will be the output of the following Python code?
s1={1, 2, 3, 8}
s2={3, 4, 5, 6}
s1|s2
s1.union(s2)
a)
{3}
{1, 2, 3, 4, 5, 6, 8}
b)
{1, 2, 4, 5, 6, 8}
{1, 2, 4, 5, 6, 8}
c)
{3}
{3}
d)
{1, 2, 3, 4, 5, 6, 8}
{1, 2, 3, 4, 5, 6, 8}
8. What will be the output of the following Python code?
a=set('abc')
b=set('def')
b.intersection_update(a)
a
b
a)
set()
('e', 'd', 'f'}
b)
{}
{}
c)
{'b', 'c', 'a'}
set()
d)
set()
set()
9. What will be the output of the following Python code, if s1= {1, 2, 3}?
s1.issubset(s1)
a) True
b) Error
c) No output
d) False
10. What will be the output of the following Python code?
x=set('abcde')
y=set('xyzbd')
x.difference_update(y)
x
y
a)
{'a', 'b', 'c', 'd', 'e'}
{'x', 'y', 'z'}
b)
{'a', 'c', 'e'}
{'x', 'y', 'z', 'b', 'd'}
c)
{'b', 'd'}
{'b', 'd'}
d)
{'a', 'c', 'e'}
{'x', 'y', 'z'}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started