Call
whatsapp
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855
Cisco Training in Trivandrum, Trinity Technologies

No.1 Training Institute in Kerala

PYTHON QUESTIONS : PART 6

What is the output when following code is executed?

>>>names=[' Amir', 'Bear','Charlton',' Daman']

>>>print(names[-1][-1])

A

Daman

Error

n

SHOW ANSWER

What is the output when following code is executed?

>>>list("a#b#c#d".split(#'))

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

['a b c d']

['a#b#c#d']

['abcd']

SHOW ANSWER

Which of the following is a Python tuple?

[1, 2,3].

(1,2,3)

{1,2, 3)

SHOW ANSWER

What will be the output?

>>>t=(1,2,4,3)

>>>t[1:3]

(1,2)

(1,2,4)

(2,4)

(2,4,3)

SHOW ANSWER

What will be the output?

>>>t=(1,2)

>>2*t

(1,2,1,2)

[1,2,1,2]

(1,1,2,2)

[1,1,2,2]

SHOW ANSWER

1f a=(1,2,3,4), a[1:-1) is

Error;tuple slicing doesn't exist

[2,3]

(2,3,4)

(2,3)

SHOW ANSWER

What is the output of the following code?

>>>a=(2,3,4)

>>>a,b,c

Too many arguments for sum() method

The method sum() doesn't exist for tuples

12

9

SHOW ANSWER

Is the following piece of code valid?

>>a,b,c =1,2,3

>>a,b,c

Yes, [1,2,3] is printed

No invalid syntax

Yes (1,2,3) is printed

I is printed

SHOW ANSWER

1s the following piece of code valid?

Yes, 2 is printed

Yes, [2,3,4,5] is printed

No, too many values to unpack

Yes, (2,3,4,5) is printed

SHOW ANSWER

Which of the following is not the correct syntax for creating a set?

set([[1,2][3,4]])

set( 1,2,2,3,4)

set((1,2,3,4))

{1,2,3,4}

SHOW ANSWER

What is the output of the following code?

nums = set([ 1,1,2,3,3,3,4,41

print(len(nums))

7

Error, invalid syntax for formation of set

4

8

SHOW ANSWER

Which of the following statements is used to create an empty set?

{}

set()

[]

()

SHOW ANSWER

What is the output of the following piece of code?

>>>a ={5,6,7,8}

>>>b={7,5,6,8}

>>>a==b

True

False

SHOW ANSWER
BACK | NEXT
TRINITY SOFTWARE SOLUTIONS,IInd floor, Radheyam Towers, Gandhari Amman Kovil Road, Pulimood, Trivandrum - 1
0471-2334855 | 2335855 | 9447387064 | 9847003556 info@trinitytechnology.in