Question
Given a column title A as appears in an Excel sheet, return its corresponding column number. Problem Constraints 1 1 B -> 2 C ->
Given a column title A as appears in an Excel sheet, return its corresponding column number.
Problem Constraints
1 <= |A| <= 100
Input Format
First and only argument is string A.
Output Format
Return an integer
Example Input
Input 1:
1
Input 2:
28
Example Output
Output 1:
"A"
Output 2:
"AB"
Example Explanation
Explanation 1:
1 -> "A"
Explanation 2:
A-> 1
B -> 2
C -> 3
...
Z -> 26
AA -> 27
AB -> 28
Please use python 3.5+ for answering above coding question and explanation for each of the below mcqs should be clear. Please don't copy from anywhere. Thanks in advance!!
1. What will be the output of the following Python function?
hex(15)
a) f
b) 0xF
c) 0Xf
d) 0xf
2. What will be the output of the following Python code?
class Demo:
def check(self):
return " Demo's check "
def display(self):
print(self.check())
class Demo_Derived(Demo):
def check(self):
return " Derived's check "
Demo().display()
Demo_Derived().display()
a) Demo's check Derived's check
b) Demo's check Demo's check
c) Derived's check Demo's check
d) Syntax error
3. Which of the following data structures is returned by the functions globals() and locals()?
a) list
b) set
c) dictionary
d) tuple
4. Which of the following is not a valid attribute of a file object (fp)?
a) fp.name
b) fp.closed
c) fp.mode
d) fp.size
5. What will be the output of the following Python code?
l1=[10, 20, 30, [40]]
l2=copy.deepcopy(l1)
l1[3][0]=90
l1
l2
a)
[10, 20, 30, [40]]
[10, 20, 30, 90]
b) Error
c)
[10, 20, 30 [90]]
[10, 20, 30, [40]]
d)
[10, 20, 30, [40]]
[10, 20, 30, [90]]
6. What will be the output of the following Python code?
sentence = 'we are humans'
matched = re.match(r'(.*) (.*?) (.*)', sentence)
print(matched.group())
a) ('we', 'are', 'humans')
b) (we, are, humans)
c) ('we', 'humans')
d) 'we are humans'
7. What is the value of x if x = math.factorial(0)?
a) 0
b) 1
c) error
d) none of the mentioned
8. What happens if the base condition isn't defined in recursive programs?
a) Program gets into an infinite loop
b) Program runs once
c) Program runs n number of times where n is the argument given to the function
d) An exception is thrown
9. What will be the output of the following Python code?
lst = [1, 2, 3]
lst[3]
a) NameError
b) ValueError
c) IndexError
d) TypeError
10. What is the correct syntax of open() function?
a) file = open(file_name [, access_mode][, buffering])
b) file object = open(file_name [, access_mode][, buffering])
c) file object = open(file_name)
d) none of the mentioned
11. What is the value of x if x = math.sqrt(4)?
a) 2
b) 2.0
c) (2, -2)
d) (2.0, -2.0)
12. What will be the output of the following Python code?
sentence = 'horses are fast'
regex = re.compile('(?P
matched = re.search(regex, sentence)
print(matched.group(2))
a) {'animal': 'horses', 'verb': 'are', 'adjective': 'fast'}
b) ('horses', 'are', 'fast')
c) 'horses are fast'
d) 'are'
13. What will be the output of the following Python code?
fo = open("foo.txt", "wb")
print "Name of the file: ", fo.name
fo.flush()
fo.close()
a) Compilation Error
b) Runtime Error
c) No Output
d) Flushes the file when closing them
14. Which of the following creates a pattern object?
a) re.create(str)
b) re.regex(str)
c) re.compile(str)
d) re.assemble(str)
15. What will be the output of the following Python code?
re.split(r'(n\d)=', 'n1=3.1, n2=5, n3=4.565')
a) Error
b) [", 'n1', '3.1, ', 'n2', '5, ', 'n3', '4.565']
c) ['n1', '3.1, ', 'n2', '5, ', 'n3', '4.565']
d) ['3.1, ', '5, ', '4.565']
16. What will be the output of the following Python code?
odd=lambda x: bool(x%2)
numbers=[n for n in range(10)]
print(numbers)
n=list()
for i in numbers:
if odd(i):
continue
else:
break
a) [0, 2, 4, 6, 8, 10]
b) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
c) [1, 3, 5, 7, 9]
d) Error
17. What will be the output of the following Python code?
import datetime
d=datetime.date(2017,06,18)
print(d)
a) Error
b) 2017-06-18
c) 18-06-2017
d) 06-18-2017
18. What is output of print(math.pow(3, 2))?
a) 9
b) 9.0
c) None
d) None of the mentioned
19. What is setattr() used for?
a) To access the attribute of the object
b) To set an attribute
c) To check if an attribute exists or not
d) To delete an attribute
20. Which of the following functions can be used to find the coordinated universal time, assuming that the datetime module has already been imported?
a) datetime.utc()
b) datetime.datetime.utc()
c) datetime.utcnow()
d) datetime.datetime.utcnow()
21. Which of the following is not a valid namespace?
a) Global namespace
b) Public namespace
c) Built-in namespace
d) Local namespace
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