Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Determine whether an integer is a palindrome. Do this without extra space. A palindrome integer is an integer x for which reverse(x) = x where

Determine whether an integer is a palindrome. Do this without extra space.

A palindrome integer is an integer x for which reverse(x) = x where reverse(x) is x with its digit reversed.

Negative numbers are not palindromic.

Example :

Input : 12121

Output : True

Input : 123

Output : False

Python code for above cp question and mcq questions explanation is must. code will be tested on large test cases

1. What does os.getlogin() return?

a) name of the current user logged in

b) name of the superuser

c) gets a form to login as a different user

d) all of the mentioned

2. Fill in the blank such that the following Python code results in the formation of an inverted, equilateral triangle.

import turtle

t=turtle.Pen()

for i in range(0,3):

t.forward(150)

t.right(_____)

a) -60

b) 120

c) -120

d) 60

3. Which of the following functions does not necessarily accept only iterables as arguments?

a) enumerate()

b) all()

c) chr()

d) max()

4. What is the base case in the Merge Sort algorithm when it is solved recursively?

a) n=0

b) n=1

c) A list of length one

d) An empty list

5. What will be the output of the following Python code?

elements = [0, 1, 2]

def incr(x):

return x+1

print(list(map(incr, elements)))

a) [1, 2, 3]

b) [0, 1, 2]

c) error

d) none of the mentioned

6. Which of the following statements is false about recursion?

a) Every recursive function must have a base case

b) Infinite recursion can occur if the base case isn't properly mentioned

c) A recursive function makes the code easier to understand

d) Every recursive function must have a return value

7. What will be the output of the following Python code?

x = 'abcd'

print(list(map(list, x)))

a) ['a', 'b', 'c', 'd']

b) ['abcd']

c) [['a'], ['b'], ['c'], ['d']]

d) none of the mentioned

8. What will be the output of the following Python code?

x = [[0], [1]]

print(len(' '.join(list(map(str, x)))))

a) 2

b) 3

c) 7

d) 8

9. Which of the following returns a string that represents the present working directory?

a) os.getcwd()

b) os.cwd()

c) os.getpwd()

d) os.pwd()

10. Which is/are the basic I/O connections in file?

a) Standard Input

b) Standard Output

c) Standard Errors

d) All of the mentioned

11. Which of these is not a fundamental features of OOP?

a) Encapsulation

b) Inheritance

c) Instantiation

d) Polymorphism

12. Python supports the creation of anonymous functions at runtime, using a construct called __________

a) lambda

b) pi

c) anonymous

d) none of the mentioned

13. Which of the following functions clears the regular expression cache?

a) re.sub()

b) re.pos()

c) re.purge()

d) re.subn()

14. What type of inheritance is illustrated in the following Python code?

class A():

pass

class B():

pass

class C(A,B):

pass

a) Multi-level inheritance

b) Multiple inheritance

c) Hierarchical inheritance

d) Single-level inheritance

15. Lambda contains block of statements.

a) True

b) False

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions