Python/ Sample Test,Sample questions

Question:
 del t1 statement will delete the tuple named ‘t1’

1.True

2.False

3.Error

4.None of the above

Posted Date:-2021-12-13 08:43:47


Question:
 What type of error is shown by following statement?
>>>t1 =(1, 2)

>>>t2

1. ValueError

2.TypeError

3.NameError

4.None of the above

Posted Date:-2021-12-13 08:44:28


Question:
 Which of the following is not a tuple?

1. P = 1,2,3,4,5

2.Q = (‘a’, ‘b’, ‘c’)

3. R = (1, 2, 3, 4)

4.None of the above

Posted Date:-2021-12-13 08:32:43


Question:
 Which of the following is/are features of tuple?

1.Tuple is immutable

2.Tuple is a sequence data type

3.In tuple, elements are enclosed in Parenthesis.

4.All the above

Posted Date:-2021-12-13 08:31:58


Question:
 Which of the following statement will create an empty tuple?

1.P = ( ) b.

2.Q = tuple( )

3.Both of the above

4.None of the above

Posted Date:-2021-12-13 08:33:18


Question:
 Write the output of the following:
>>>t1= ('a', 'b')

>>>t2 = (1,2,3)

>>>t2+t1

1.(‘a’, ‘b’, 1, 2, 3)

2.(1, 2, 3, ‘a’, ‘b’)

3.(1, ‘a’, 2, ‘b’, 3)

4.None of the above

Posted Date:-2021-12-13 08:36:59


Question:
 Write the output of the following:
a=(1, 2, 3, 2, 3, 4, 5)
print(min(a) + max(a) + a.count(2))

1.13

2.6

3.8

4.Error

Posted Date:-2021-12-13 08:30:58


Question:
 Write the output of the following:
t1 = (23, 45, 67, 43, 21, 41)

print(t1[1:2])

1. (45)

2.(45,)

3.(45, 67)

4.None of the above

Posted Date:-2021-12-13 08:40:44


Question:
 Write the output of the following.
>>> t1=((1,2),(3,4),(9,))

>>>max(t1)

1.9

2.(9,)

3.(3,4)

4.None of the above

Posted Date:-2021-12-13 08:45:31


Question:
>>>min(t1) will return an error if the tuple t1 contains value of mixed data type.

1.True

2.False

3.Error

4.None of the above

Posted Date:-2021-12-13 08:45:50


Question:
In tuples values are enclosed in __________________

1.a. Square brackets

2.Curly brackets

3.Parenthesis

4.None of the above

Posted Date:-2021-12-13 08:25:56


Question:
Tuples are __________________

1.Mutable

2.Immutable

3.Mutable to some extent

4.None of the above

Posted Date:-2021-12-13 08:25:04


Question:
What is the length of the given tuple? >>> t1=(1,2,(3,4,5)

1.1

2.2

3.3

4.4

Posted Date:-2021-12-13 08:35:22


Question:
What type of error is returned by following code :
a=(“Amit”, “Sumit”,”Ashish”,”Sumanta”)
print(a.index(“Suman”))

1.SyntaxError

2.ValueError

3.TypeError

4.NameError

Posted Date:-2021-12-13 08:55:04


Question:
Which function returns the length of tuple?

1.a. length( )

2.len( )

3.size( )

4.None of the above

Posted Date:-2021-12-13 08:42:12


Question:
Which mathematical operator is used to replicate a tuple?

1. Addition

2.Multiplication

3.Exponent

4.Modulus

Posted Date:-2021-12-13 08:40:01


Question:
Which of the following function return the frequency of particular element in tuple?

1.index( )

2. max( )

3.count( )

4.None of the above

Posted Date:-2021-12-13 08:47:01


Question:
Which of the following function return the frequency of particular element in tuple?

1.index( )

2. max( )

3.count( )

4.None of the above

Posted Date:-2021-12-13 08:47:08


Question:
Which of the following function return the frequency of particular element in tuple?

1.index( )

2. max( )

3.count( )

4.None of the above

Posted Date:-2021-12-13 08:47:10


Question:
Which of the following is a tuple with single element?

1.t = (1,)

2. t = 1,

3.Both of the above

4.None of the above

Posted Date:-2021-12-13 08:34:03


Question:
Which of the following is not a function of tuple?

1.update( )

2.min( )

3.max( )

4.count( )

Posted Date:-2021-12-13 08:29:39


Question:
Which of the following statement will return an error. T1 is a tuple.

1.T1 + (23)

2. T1 + [3]

3.Both of the above

4.None of the above

Posted Date:-2021-12-13 08:38:02


Question:
Write the output of the following :
>>> t1=(1,2,3,4,5,6,7)
Write the output of the following:
a=(“Amit”, “Sumit”,”Ashish”,”Sumanta”)
print(max(a))
>>> t1[t1[1]]

1.Sumanta

2.Ashish

3.Sumit

4.Amit

Posted Date:-2021-12-13 08:54:20


Question:
Write the output of the following :
>>>t1 = (1,2)

>>> t2 = (1.0, 2.0)

>>> t1 == t2

1.True

2.False

3.Error

4.None of the above

Posted Date:-2021-12-13 08:43:13


Question:
Write the output of the following :
>>>t1 = (1,2)

>>> t2 = (2,1)

>>> t1 == t2

1.True

2.False

3.Error

4.None of the above

Posted Date:-2021-12-13 08:42:45


Question:
Write the output of the following :
a=("Amit", "Sumit","Ashish","Sumanta")
for i in a:
    print(len(i)**2)

1.0 1 4 9

2.16 25 36 49

3.Error

4.1 4 9 16

Posted Date:-2021-12-13 09:15:20


Question:
Write the output of the following :
a=("Hello","How","are","you")
for i in a:
    print(i,end=" ")

1.“Hello” , “How” , “are” , “you”

2. Hello , How , are , you

3. Hello How are you

4.Error

Posted Date:-2021-12-13 09:18:37


Question:
Write the output of the following :
a=(“Amit”, “Sumit”,”Ashish”,”Sumanta”)
print(a.index(“Sumit”)+4//3**2)

1.2

2.4

3.1

4.3

Posted Date:-2021-12-13 08:55:32


Question:
Write the output of the following:
>>>t = (1)
>>>type(t)

1.<class ‘int’>

2.<class ‘float’>

3.<class ‘tuple’>

4.<class ‘list’>

Posted Date:-2021-12-13 08:34:52


Question:
Write the output of the following:
>>>t1 = (1,2,3,4,5)

>>>t2=t1

>>>t2

1.Error

2.(1,2,3,4,5)

3.1,2,3,4,5

4.[1,2,3,4,5]

Posted Date:-2021-12-13 08:36:14


Question:
Write the output of the following:
A = list(tuple(“Python”))
print(A)

1.(‘P’, ‘y’, ‘t’, ‘h’, ‘o’, ‘n’)

2.[‘P’, ‘y’, ‘t’, ‘h’, ‘o’, ‘n’]

3.Error

4.None of the above

Posted Date:-2021-12-13 08:28:14


Question:
Write the output of the following:
a=("Hello","How","are","you")
for i in a:
    print(a.index(i),end=" ")

1.0 1 2 3

2.“Hello” , “How” , “are” , “you”

3.Error

4.0 2 3

Posted Date:-2021-12-13 09:19:25


Question:
Write the output of the following:
a=(23,34,65,20,5)
s=0
for i in a:
    if i%2==0:
         s=s+a[i]
print(s)

1.54

2.93

3.94

4.Error

Posted Date:-2021-12-13 08:30:21


Question:
Write the output of the following:
a=(6,8,9,"Sumanta",1)
for i in a:
      print(str(i)*2)

1.66 88 99 SumantaSumanta 11

2.66 88 99 Error

3.Error

4.66 88 99 SumantaSumanta Error

Posted Date:-2021-12-13 09:16:14


Question:
Write the output of the following:
a=(“Amit”, “Sumit”,”Ashish”,”Sumanta”)
print(a.count(“Sum”))

1.1

2.2

3.0

4.Error

Posted Date:-2021-12-13 09:13:32


Question:
Write the output of the following:
a=(“Hello”,”How”,”are”,”you”)
b=list(a)
print(a==b)

1.SyntaxError b. c.

2. ValueError

3.True

4.False

Posted Date:-2021-12-13 09:20:35


Question:
Write the output of the following:
a="blog"
b=list(a)
c=tuple(b)
print(c)

1.Error b.

2. [‘b’ , ‘l’ , ‘o’ , ‘g’]

3.(‘b’ , ‘l’ , ‘o’ , ‘g’) d. (blog)

4.(blog)

Posted Date:-2021-12-13 09:17:52


Question:
Write the output of the following:
t1 = ('1', '2', '3', '4', '5')

print(t1 + tuple("tuple"))

1.(‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘t’, ‘u’, ‘p’, ‘l’, ‘e’)

2.(‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘tuple’)

3.Error

4.None of the above

Posted Date:-2021-12-13 08:41:29


Question:
Write the output of the following.
A = tuple(“Python”)
print(A)

1.(python)

2.(“Python”)

3.(‘P’ , ‘y’ , ‘t’ , ‘h’ , ‘o’ , ‘n’)

4.None of the above

Posted Date:-2021-12-13 08:27:15


Question:
Write the output of the following.
a=(23,34,65,20,5)
print(a[0]+a.index(5))

1.28

2.29

3.27

4.26

Posted Date:-2021-12-13 08:28:51


More MCQS

  1. help4info.com
  2. help4info.com
  3. help4info.com
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!