Thursday, November 4, 2021

JNTUH B Tech Python Programming MCQ's

 1. Which of these in not a core data type?

a) Lists
b) Dictionary
c) Tuples
d) Class
2. Given a function that does not return any value, What value is thrown by default when executed in shell.
a) int
b) bool
c) void
d) None
3. Following set of commands are executed in shell, what will be the output?

1.     >>>str="hello"

2.     >>>str[:2]

3.     >>> 

a) he
b) lo
c) olleh
d) hello

4. What data type is the object below ?

L = [1, 23, ‘hello’, 1].
a) list
b) dictionary
c) array
d) tuple
5. In order to store values in terms of key and value we use what core data type.

a) list
b) tuple
c) class
d) dictionary

6. Which is the correct operator for power(xy)?

a) X^y
b) X**y
c) X^^y
d) None of the mentioned

7. Which one of these is floor division?
a) /
b) //
c) %
d) None of the mentioned

8. What is the order of precedence in python?
i) Parentheses
ii) Exponential
iii) Multiplication
iv) Division
v) Addition
vi) Subtraction
a) i,ii,iii,iv,v,vi
b) ii,i,iii,iv,v,vi
c) ii,i,iv,iii,v,vi
d) i,ii,iii,iv,vi,v

9. What is the answer to this expression, 22 % 3 is?
a) 7
b) 1
c) 0
d) 5

10. What is the output of this expression, 3*1**3?
a) 27
b) 9
c) 3
d) 1

11. Which of the following is not a complex number?

a) k = 2 + 3j
b) k = complex(2, 3)
c) k = 2 + 3l
d) k = 2 + 3J

12. What does 3 ^ 4 evaluate to?
a) 81
b) 12
c) 0.75
d) 7

13. What is the output of the code snippet shown below?

X=”hi”

print(“05d”%X)

a) 00000hi
b) 000hi
c) hi000
d) error

14. What is the output of the following expression if x=456?

print("%-06d"%x)

a) 000456
b) 456000
c) 456
d) error
15. What is the output of the following expression if X=345?

print(“%06d”%X)

a) 345000
b) 000345
c) 000000345
d) 345000000

16. What is the result of the expression shown below if x=56.236?

print("%.2f"%x)

a) 56.00
b) 56.24
c) 56.23
d) 0056.236

17. The output of the code shown below is:

s='{0}, {1}, and {2}'

s.format('hello', 'good', 'morning')

a) ‘hello good and morning’
b) ‘hello, good, morning’
c) ‘hello, good, and morning’
d) Error

18. What is the output of the code shown?

s='%s, %s & %s'

s%('mumbai', 'kolkata', 'delhi')

a) mumbai kolkata & delhi
b) Error
c) No output
d) ‘mumbai, kolkata & delhi’

19. What is the output of the following?

x = ['ab', 'cd']

for i in x:

    x.append(i.upper())

print(x)

a) [‘AB’, ‘CD’].
b) [‘ab’, ‘cd’, ‘AB’, ‘CD’].
c) [‘ab’, ‘cd’].
d) none of the mentioned

20. What is the output of the following?

i = 1

while True:

    if i%3 == 0:

        break

    print(i,end=’ ‘)

    i + = 1

a) 1 2
b) 1 2 3
c) error
d) none of the mentioned

21. What is the output of the following?

i = 1

while True:

    if i%2 == 0:

        break

    print(i)

    i += 2

a) 1
b) 1 2
c) 1 2 3 4 5 6 …
d) 1 3 5 7 9 11 …

22. What is the output when following statement is executed ?

1.     >>>"abcd"[2:]

a) a
b) ab
c) cd
d) dc

23. What is the output when following code is executed ?

1.     >>> str1 = 'hello'

2.     >>> str1[-1:]

a) olleh
b) hello
c) h
d) o

24. What arithmetic operators cannot be used with strings ?
a) +
b) *
c) –
d) All of the mentioned

25. What is the output when following code is executed ?

1.     >>>str1="helloworld"

2.     >>>str1[::-1]

a) dlrowolleh
b) hello
c) world
d) helloworld

26. What is the output of the following?

print("ccdcddcd".find("c"))

a) 4
b) 0
c) Error
d) True

27. What is the output of the following?

print("Hello {0} and {1}".format('foo', 'bin'))

a) Hello foo and bin
b) Hello {0} and {1} foo bin
c) Error
d) Hello 0 and 1

28. What is the output of the following?

print('abc'.islower())

a) True
b) False
c) None
d) Error

29. Which of the following commands will create a list?
a) list1 = list()
b) list1 = [].
c) list1 = list([1, 2, 3])
d) all of the mentioned

30. What is the output when we execute list(“hello”)?
a) [‘h’, ‘e’, ‘l’, ‘l’, ‘o’].
b) [‘hello’].
c) [‘llo’].
d) [‘olleh’].

31. Suppose listExample is [‘h’,’e’,’l’,’l’,’o’], what is len(listExample)?
a) 5
b) 4
c) None
d) Error

32. Suppose list1 is [2445,133,12454,123], what is max(list1) ?
a) 2445
b) 133
c) 12454
d) 123

33. Suppose list1 is [1, 5, 9], what is sum(list1) ?
a) 1
b) 9
c) 15
d) Error

34. Suppose list1 is [2, 33, 222, 14, 25], What is list1[-1] ?
a) Error
b) None
c) 25
d) 2

35. What is the output of the following code?

a=[1,2,3]

b=a.append(4)

print(a)

print(b)

a) [1,2,3,4].
[1,2,3,4].
b) [1, 2, 3, 4].
None
c) Syntax error
d) [1,2,3].
[1,2,3,4].

36. What will be the output when executed in python shell?

>>> a=[14,52,7]

>>>> b=a.copy()

>>> b is a

a) True
b) False

37. What is the output of the following code?

a=[13,56,17]

a.append([87])

a.extend([45,67])

print(a)

a) [13, 56, 17, [87], 45, 67].
b) [13, 56, 17, 87, 45, 67].
c) [13, 56, 17, 87,[ 45, 67]].
d) [13, 56, 17, [87], [45, 67]].

38. What is the output of the following piece of code?

a=list((45,)*4)

print((45)*4)

print(a)

a) 180
[(45),(45),(45),(45)].
b) (45,45,45,45).
[45,45,45,45].
c) 180
[45,45,45,45].
d) Syntax error

39. What is the output of the following code?

lst=[[1,2],[3,4]]

print(sum(lst,[]))

a) [[3],[7]].
b) [1,2,3,4].
c) Error
d) [10].

40. What is the output of the following code?

word1="Apple"

word2="Apple"

list1=[1,2,3]

list2=[1,2,3]

print(word1 is word2)

print(list1 is list2)

a) True
True
b) False
True
c) False
False
d) True
False

41. What is the output of the following piece of code?

x=[[1],[2]]

print(" ".join(list(map(str,x))))

a) [1] [2].
b) [49] [50].
c) Syntax error
d) [[1]] [[2]].

42. What is the output of the following code?

a=165

b=sum(list(map(int,str(a))))

print(b)

a) 561
b) 5
c) 12
d) Syntax error

43. What is the output of the following code?

a= [1, 2, 3, 4, 5]

for i in range(1, 5):

    a[i-1] = a[i]

for i in range(0, 5):

    print(a[i],end = " ")

a) 5 5 1 2 3
b) 5 1 2 3 4
c) 2 3 4 5 1
d) 2 3 4 5 5

44. What is the output of the following code?

num = ['One', 'Two', 'Three']

for i, x in enumerate(num):

    print('{}: {}'.format(i, x),end=" ")

a) 1: 2: 3:
b) Exception is thrown
c) One Two Three
d) 0: One 1: Two 2: Three

45. Which of the following is a Python tuple?
a) [1, 2, 3].
b) (1, 2, 3)
c) {1, 2, 3}
d) {}

46. Suppose t = (1, 2, 4, 3), which of the following is incorrect?
a) print(t[3])
b) t[3] = 45
c) print(max(t))
d) print(len(t))

47. What will be the output?

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

2.     >>>t[1:3]

a) (1, 2)
b) (1, 2, 4)
c) (2, 4)
d) (2, 4, 3)

48. What will be the output?

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

2.     >>>t[1:-1]

a) (1, 2)
b) (1, 2, 4)
c) (2, 4)
d) (2, 4, 3)

49. What will be the output?

1.     >>>t = (1, 2, 4, 3, 8, 9)

2.     >>>[t[i] for i in range(0, len(t), 2)]

a) [2, 3, 9].
b) [1, 2, 4, 3, 8, 9].
c) [1, 4, 8].
d) (1, 4, 8)

50. What will be the output?

1.     d = {"john":40, "peter":45}

2.     d["john"]

a) 40
b) 45
c) “john”
d) “peter”

50. What is the output of the code shown?
x=3.3456789
'%s' %x, str(x)
a) Error
b) (‘3.3456789’, ‘3.3456789’)
c) (3.3456789, 3.3456789)
d) (‘3.3456789’, 3.3456789)

51. What is the output of the code shown?
'%(qty)d more %(food)s' %{'qty':1, 'food': 'spam'}
a) Error
b) No output
c) ‘1 more foods’
d) ‘1 more spam’

52. What is the output of the code shown?
a='hello'
q=10
vars()
a) {‘a’ : ‘hello’, ‘q’ : 10, ……..plus built-in names set by Python….}
b) {……Built in names set by Python……}
c) {‘a’ : ‘hello’, ‘q’ : 10}
d) Error

53. The output of the code shown below is:
s='{0}, {1}, and {2}'
s.format('hello', 'good', 'morning')
a) ‘hello good and morning’
b) ‘hello, good, morning’
c) ‘hello, good, and morning’
d) Error

54. What is the output of the code shown?
s='%s, %s & %s'
s%('mumbai', 'kolkata', 'delhi')
a) mumbai kolkata & delhi
b) Error
c) No output
d) ‘mumbai, kolkata & delhi’

55. What is the output of the code shown below?
t = '%(a)s, %(b)s, %(c)s'
t % dict(a='hello', b='world', c='universe')
a) ‘hello, world, universe’
b) ‘hellos, worlds, universes’
c) Error
d) hellos, world, universe

56. What is the output of the code shown?
'{a}, {0}, {abc}'.format(10, a=2.5, abc=[1, 2])
a) Error
b) ‘2.5, 10, [1, 2]’
c) 2.5, 10, 1, 2
d) ’10, 2.5, [1, 2]’

57. What is the output of the code shown below?
'{0:.2f}'.format(1.234)
a) ‘1’
b) ‘1.234’
c) ‘1.23’
d) ‘1.2’

58. What is the output of the code shown below?
'%x %d' %(255, 255)
a) ‘ff, 255’
b) ‘255, 255’
c) ‘15f, 15f’
d) Error

59. The output of the two codes shown below is the same. State whether true or false.
'{0:.2f}'.format(1/3.0)
'%.2f'%(1/3.0)
a) True
b) False
60. What is the output of the following?
x = ['ab', 'cd']
for i in x:
    i.upper()
print(x)
a) [‘ab’, ‘cd’].
b) [‘AB’, ‘CD’].
c) [None, None].
d) none of the mentioned

61. What is the output of the following?
x = ['ab', 'cd']
for i in x:
    x.append(i.upper())
print(x)
a) [‘AB’, ‘CD’].
b) [‘ab’, ‘cd’, ‘AB’, ‘CD’].
c) [‘ab’, ‘cd’].
d) none of the mentioned

62. What is the output of the following?
i = 1
while True:
    if i%3 == 0:
        break
    print(i)
 
    i + = 1
a) 1 2
b) 1 2 3
c) error
d) none of the mentioned

63. What is the output of the following?
i = 1
while True:
    if i%0O7 == 0:
        break
    print(i)
    i += 1
a) 1 2 3 4 5 6
b) 1 2 3 4 5 6 7
c) error
d) none of the mentioned

64. What is the output of the following?
i = 5
while True:
    if i%0O11 == 0:
        break
    print(i)
    i += 1
a) 5 6 7 8 9 10
b) 5 6 7 8
c) 5 6
d) error

65. What is the output of the following?
i = 5
while True:
    if i%0O9 == 0:
        break
    print(i)
    i += 1
a) 5 6 7 8
b) 5 6 7 8 9
c) 5 6 7 8 9 10 11 12 13 14 15 ….
d) error

66. What is the output of the following?
i = 1
while True:
    if i%2 == 0:
        break
    print(i)
    i += 2
a) 1
b) 1 2
c) 1 2 3 4 5 6 …
d) 1 3 5 7 9 11 …

67. What is the output of the following?
i = 2
while True:
    if i%3 == 0:
        break
    print(i)
    i += 2
a) 2 4 6 8 10 …
b) 2 4
c) 2 3
d) error

68. What is the output of the following?
i = 1
while False:
    if i%2 == 0:
        break
    print(i)
    i += 2
a) 1
b) 1 3 5 7 …
c) 1 2 3 4 …
d) none of the mentioned

69. What is the output of the following?
True = False
while True:
    print(True)
    break
a) True
b) False
c) None
d) none of the mentioned
70. What is the output when following statement is executed ?
1.     >>>"a"+"bc"
a) a
b) bc
c) bca
d) abc

71. What is the output when following statement is executed ?
1.     >>>"abcd"[2:]
a) a
b) ab
c) cd
d) dc

72. The output of executing string.ascii_letters can also be achieved by:
a) string.ascii_lowercase_string.digits
b) string.ascii_lowercase+string.ascii_upercase
c) string.letters
d) string.lowercase_string.upercase

73. What is the output when following code is executed ?
1.     >>> str1 = 'hello'
2.     >>> str2 = ','
3.     >>> str3 = 'world'
4.     >>> str1[-1:]
a) olleh
b) hello
c) h
d) o

74. What arithmetic operators cannot be used with strings ?
a) +
b) *
c) –
d) All of the mentioned

75. What is the output when following code is executed ?
1.     >>>print (r"\nhello")
a) a new line and hello
b) \nhello
c) the letter r and then hello
d) error

76. What is the output when following statement is executed ?
1.     >>>print('new' 'line')
a) Error
b) Output equivalent to print ‘new\nline’
c) newline
d) new line

77. What is the output when following statement is executed ?
>>> print(‘x\97\x98’)
a) Error
b) 97
98
c) x\97
d) \x97\x98

78. What is the output when following code is executed ?
1.     >>>str1="helloworld"
2.     >>>str1[::-1]
a) dlrowolleh
b) hello
c) world
d) helloworld

79. print(0xA + 0xB + 0xC) :
a) 0xA0xB0xC
b) Error
c) 0x22
d) 33
80. What is the output of the following?
print("ab\tcd\tef".expandtabs())
a) ab cd ef
b) abcdef
c) ab\tcd\tef
d) ab cd ef

81. What is the output of the following?
print("ab\tcd\tef".expandtabs(4))
a) ab cd ef
b) abcdef
c) ab\tcd\tef
d) ab cd ef

82. What is the output of the following?
print("ab\tcd\tef".expandtabs('+'))
a) ab+cd+ef
b) ab++++++++cd++++++++ef
c) ab cd ef
d) none of the mentioned

83. What is the output of the following?
print("abcdef".find("cd") == "cd" in "abcdef")
a) True
b) False
c) Error
d) None of the mentioned

84. What is the output of the following?
print("abcdef".find("cd"))
a) True
b) 2
c) 3
d) None of the mentioned

85. What is the output of the following?
print("ccdcddcd".find("c"))
a) 4
b) 0
c) Error
d) True

86. What is the output of the following?
print("Hello {0} and {1}".format('foo', 'bin'))
a) Hello foo and bin
b) Hello {0} and {1} foo bin
c) Error
d) Hello 0 and 1

87. What is the output of the following?
print("Hello {1} and {0}".format('bin', 'foo'))
a) Hello foo and bin
b) Hello bin and foo
c) Error
d) None of the mentioned

88. What is the output of the following?
print("Hello {} and {}".format('foo', 'bin'))
a) Hello foo and bin
b) Hello {} and {}
c) Error
d) Hello and

89. What is the output of the following?
print("Hello {name1} and {name2}".format('foo', 'bin'))
a) Hello foo and bin
b) Hello {name1} and {name2}
c) Error
d) Hello and
90. What is the output of the following?
print('for'.isidentifier())
a) True
b) False
c) None
d) Error

91. What is the output of the following?
print('abc'.islower())
a) True
b) False
c) None
d) Error

92. What is the output of the following?
print('a@ 1,'.islower())
a) True
b) False
c) None
d) Error

93. What is the output of the following?
print('11'.isnumeric())
a) True
b) False
c) None
d) Error

94. What is the output of the following?
print('1.1'.isnumeric())
a) True
b) False
c) None
d) Error

95. What is the output of the following?
print('1@ a'.isprintable())
a) True
b) False
c) None
d) Error
96. What is the output of the following?
print(''''''.isspace())
a) True
b) False
c) None
d) Error

97. What is the output of the following?
print('\t'.isspace())
a) True
b) False
c) None
d) Error

98. What is the output of the following?
print('HelloWorld'.istitle())
a) True
b) False
c) None
d) Error

99. What is the output of the following?
print('Hello World'.istitle())
a) True
b) False
c) None
d) Error
100. Which of the following commands will create a list?
a) list1 = list()
b) list1 = [].
c) list1 = list([1, 2, 3])
d) all of the mentioned

1 comment:

  1. Top soccer bet of 2021 for korean players
    Top soccer worrione bet of งานออนไลน์ 2021 for korean players · 10% of the wagers are on the Premier League · Only one sports team and one team 1xbet korean from the

    ReplyDelete