9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855

### 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

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']

Which of the following is a Python tuple?

[1, 2,3].

(1,2,3)

{1,2, 3)

What will be the output?

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

>>>t[1:3]

(1,2)

(1,2,4)

(2,4)

(2,4,3)

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]

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

Error;tuple slicing doesn't exist

[2,3]

(2,3,4)

(2,3)

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

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

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

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}

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

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

{}

set()

[]

()

What is the output of the following piece of code?

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

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

>>>a==b

True

False