Python/ Sample Test,Sample questions

Question:
 What will be the output of the following Python code snippet?

for i in [1, 2, 3, 4][::-1]:
    print (i)

1.1 2 3 4

2.4 3 2 1

3.error

4.none of the mentioned

Posted Date:-2021-12-30 06:55:58


Question:
 What will be the output of the following Python code snippet?

for i in ''.join(reversed(list('abcd'))):
    print (i)

1.a b c d

2.d c b a

3. error

4. None of the mentioned

Posted Date:-2021-12-30 06:56:29


Question:
 What will be the output of the following Python code?

d = {0: 'a', 1: 'b', 2: 'c'}
for i in d:
    print(i)

1. 0 1 2

2.a b c

3. 0 a 1 b 2 c

4.none of the mentioned

Posted Date:-2021-12-30 06:44:22


Question:
 What will be the output of the following Python code?

i = 1
while False:
    if i%2 == 0:
        break
    print(i)
    i += 2

1.1

2.1 3 5 7 …

3. 1 2 3 4 …

4. None of the mentioned

Posted Date:-2021-12-30 03:00:44


Question:
 What will be the output of the following Python code?

x = ['ab', 'cd']
for i in x:
    i.upper()
print(x)

1. [‘ab’, ‘cd’]

2. [‘AB’, ‘CD’]

3.[None, None]

4.none of the mentioned

Posted Date:-2021-12-30 02:56:28


Question:
 What will be the output of the following Python code?

x = ['ab', 'cd']
for i in x:
    x.append(i.upper())
print(x)

1.[‘AB’, ‘CD’]

2.[‘ab’, ‘cd’, ‘AB’, ‘CD’]

3. [‘ab’, ‘cd’]

4. None of the mentioned

Posted Date:-2021-12-30 02:57:14


Question:
What will be the output of the following Python code snippet?

for i in '':
    print (i)

1.None

2.(nothing is printed)

3.error

4.none of the mentioned

Posted Date:-2021-12-30 06:59:23


Question:
What will be the output of the following Python code snippet?

for i in 'abcd'[::-1]:
    print (i)

1. a b c d

2.d c b a

3. error

4.none of the mentioned

Posted Date:-2021-12-30 06:57:03


Question:
What will be the output of the following Python code snippet?

x = 'abcd'
for i in range(len(x)):
    i.upper()
print (x)

1.a b c d

2. 0 1 2 3

3.error

4.none of the mentioned

Posted Date:-2021-12-30 03:57:05


Question:
What will be the output of the following Python code snippet?

x = 'abcd'
for i in range(len(x)):
    i[x].upper()
print (x)

1. abcd

2.ABCD

3.error

4.none of the mentioned

Posted Date:-2021-12-30 03:57:54


Question:
What will be the output of the following Python code snippet?

x = 'abcd'
for i in range(len(x)):
    print(x)
    x = 'a'

1.a

2.abcd abcd abcd abcd

3. a a a a

4. None of the mentioned

Posted Date:-2021-12-30 03:59:05


Question:
What will be the output of the following Python code snippet?

x = 'abcd'
for i in range(len(x)):
    x = 'a'
    print(x)

1. a

2.abcd abcd abcd

3. a a a a

4.none of the mentioned

Posted Date:-2021-12-30 03:58:39


Question:
What will be the output of the following Python code snippet?

x = 'abcd'
for i in range(len(x)):
    x[i].upper()
print (x)

1.abcd

2.ABCD

3.error

4. None of the mentioned

Posted Date:-2021-12-30 03:57:32


Question:
What will be the output of the following Python code snippet?

x = 2
for i in range(x):
    x -= 2
    print (x)

1. 0 1 2 3 4 …

2. 0 -2

3.0

4.error

Posted Date:-2021-12-30 07:00:46


Question:
What will be the output of the following Python code snippet?

x = 2
for i in range(x):
    x += 1
    print (x)

1. 0 1 2 3 4 …

2.0 1

3.3 4

4. 0 1 2 3

Posted Date:-2021-12-30 07:00:18


Question:
What will be the output of the following Python code?

d = {0, 1, 2}
for x in d:
    print(d.add(x))

1. 0 1 2

2. 0 1 2 0 1 2 0 1 2 …

3.None None None

4.none of the mentioned

Posted Date:-2021-12-30 06:52:02


Question:
What will be the output of the following Python code?

d = {0, 1, 2}
for x in d:
    print(x)

1. 0 1 2

2.{0, 1, 2} {0, 1, 2} {0, 1, 2}

3.error

4.none of the mentioned

Posted Date:-2021-12-30 06:51:14


Question:
What will be the output of the following Python code?

d = {0, 1, 2}
for x in d.values():
    print(x)

1.0 1 2

2.None None None

3. error

4. None of the mentioned

Posted Date:-2021-12-30 06:50:47


Question:
What will be the output of the following Python code?

d = {0: 'a', 1: 'b', 2: 'c'}
for x in d.keys():
    print(d[x])

1.0 1 2

2.a b c

3.0 a 1 b 2 c

4.none of the mentioned

Posted Date:-2021-12-30 06:47:36


Question:
What will be the output of the following Python code?

d = {0: 'a', 1: 'b', 2: 'c'}
for x in d.values():
    print(d[x])

1. 0 1 2

2. a b c

3.0 a 1 b 2 c

4.none of the mentioned

Posted Date:-2021-12-30 06:50:07


Question:
What will be the output of the following Python code?

d = {0: 'a', 1: 'b', 2: 'c'}
for x in d.values():
    print(x)

1.0 1 2

2. a b c

3.0 a 1 b 2 c

4.none of the mentioned

Posted Date:-2021-12-30 06:49:41


Question:
What will be the output of the following Python code?

d = {0: 'a', 1: 'b', 2: 'c'}
for x, y in d:
    print(x, y)

1. 0 1 2

2.a b c

3. 0 a 1 b 2 c

4. None of the mentioned

Posted Date:-2021-12-30 06:44:56


Question:
What will be the output of the following Python code?

d = {0: 'a', 1: 'b', 2: 'c'}
for x, y in d.items():
    print(x, y)

1. 0 1 2

2.a b c

3. 0 a 1 b 2 c

4.none of the mentioned

Posted Date:-2021-12-30 06:46:41


Question:
What will be the output of the following Python code?

for i in range(0):
    print(i)

1. 0

2.no output

3.error

4.none of the mentioned

Posted Date:-2021-12-30 06:52:29


Question:
What will be the output of the following Python code?

for i in range(2.0):
    print(i)

1. 0.0 1.0

2. 0 1

3.error

4.none of the mentioned

Posted Date:-2021-12-30 06:53:23


Question:
What will be the output of the following Python code?

for i in range(5):
    if i == 5:
        break
    else:
        print(i)
else:
    print("Here")

1. 0 1 2 3 4 Here

2.0 1 2 3 4 5 Here

3.0 1 2 3 4

4.1 2 3 4 5

Posted Date:-2021-12-30 07:01:37


Question:
What will be the output of the following Python code?

for i in range(float('inf')):
    print (i)

1.0.0 0.1 0.2 0.3 …

2.0 1 2 3 …

3.0.0 1.0 2.0 3.0 …

4.none of the mentioned

Posted Date:-2021-12-30 06:54:58


Question:
What will be the output of the following Python code?

for i in range(int(2.0)):
    print(i)

1.0.0 1.0

2. 0 1

3.error

4.none of the mentioned

Posted Date:-2021-12-30 06:54:34


Question:
What will be the output of the following Python code?

for i in range(int(float('inf'))):
    print (i)

1.0.0 0.1 0.2 0.3 …

2.0 1 2 3 …

3.0.0 1.0 2.0 3.0 …

4.none of the mentioned

Posted Date:-2021-12-30 06:55:23


Question:
What will be the output of the following Python code?

i = 0
while i < 3:
    print(i)
    i += 1
else:
    print(0)

1.0 1 2 3 0

2. 0 1 2 0

3. 0 1 2

4.error

Posted Date:-2021-12-30 03:02:21


Question:
What will be the output of the following Python code?

i = 0
while i < 5:
    print(i)
    i += 1
    if i == 3:
        break
else:
    print(0)

1.0 1 2 0

2.0 1 2

3. error

4.none of the mentioned

Posted Date:-2021-12-30 03:01:53


Question:
What will be the output of the following Python code?

i = 1
while True:
    if i%0O7 == 0:
        break
    print(i)
    i += 1

1. 1 2 3 4 5 6

2. 1 2 3 4 5 6 7

3.error

4.none of the mentioned

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


Question:
What will be the output of the following Python code?

i = 1
while True:
    if i%2 == 0:
        break
    print(i)
    i += 2

1.1

2.1 2

3.1 2 3 4 5 6 …

4. 1 3 5 7 9 11 …

Posted Date:-2021-12-30 02:59:57


Question:
What will be the output of the following Python code?

i = 2
while True:
    if i%3 == 0:
        break
    print(i)
    i += 2

1.2 4 6 8 10 …

2.2 4

3. 2 3

4.error

Posted Date:-2021-12-30 03:00:19


Question:
What will be the output of the following Python code?

i = 5
while True:
    if i%0O11 == 0:
        break
    print(i)
    i += 1

1. 5 6 7 8 9 10

2. 5 6 7 8

3. 5 6

4. error

Posted Date:-2021-12-30 02:58:41


Question:
What will be the output of the following Python code?

i = 5
while True:
    if i%0O9 == 0:
        break
    print(i)
    i += 1

1.5 6 7 8

2.5 6 7 8 9

3.5 6 7 8 9 10 11 12 13 14 15 ….

4.error

Posted Date:-2021-12-30 02:59:09


Question:
What will be the output of the following Python code?

i = 5
while True:
    if i%0O9 == 0:
        break
    print(i)
    i += 1

1.5 6 7 8

2.5 6 7 8 9

3.5 6 7 8 9 10 11 12 13 14 15 ….

4.error

Posted Date:-2021-12-30 02:59:14


Question:
What will be the output of the following Python code?

True = False
while True:
    print(True)
    break

1. True

2.False

3. None

4.none of the mentioned

Posted Date:-2021-12-30 03:01:07


Question:
What will be the output of the following Python code?

x = 'abcd'
for i in range(len(x)):
    print(i.upper())

1.a b c d

2. 0 1 2 3

3. error

4. 1 2 3 4

Posted Date:-2021-12-30 03:48:35


Question:
What will be the output of the following Python code?

x = 'abcd'
for i in range(x):
    print(i)

1. a b c d

2. 0 1 2 3

3.error

4.none of the mentioned

Posted Date:-2021-12-30 03:47:33


Question:
What will be the output of the following Python code?

x = 'abcd'
for i in x:
    print(i)
    x.upper()

1. a B C D

2.a b c d

3.A B C D

4.error

Posted Date:-2021-12-30 03:06:21


Question:
What will be the output of the following Python code?

x = "abcdef"
i = "a"
while i in x:
    print('i', end = " ")

1. no output

2. i i i i i i …

3. a a a a a a …

4.a b c d e f

Posted Date:-2021-12-30 03:03:53


Question:
What will be the output of the following Python code?

x = "abcdef"
i = "a"
while i in x:
    print(i, end = " ")

1.no output

2. i i i i i i …

3.a a a a a a …

4.a b c d e f

Posted Date:-2021-12-30 03:03:33


Question:
What will be the output of the following Python code?

x = "abcdef"
i = "a"
while i in x:
    x = x[:-1]
    print(i, end = " ")

1. i i i i i i

2. a a a a a a

3.a a a a a

4.none of the mentioned

Posted Date:-2021-12-30 03:04:24


Question:
What will be the output of the following Python code?

x = "abcdef"
i = "a"
while i in x:
    x = x[1:]
    print(i, end = " ")

1. a a a a a a

2.a

3. no output

4. error

Posted Date:-2021-12-30 03:05:19


Question:
What will be the output of the following Python code?

x = "abcdef"
i = "a"
while i in x[:-1]:
    print(i, end = " ")

1.a a a a a

2.a a a a a a

3. a a a a a a …

4. a

Posted Date:-2021-12-30 03:04:48


Question:
What will be the output of the following Python code?

x = "abcdef"
i = "a"
while i in x[1:]:
    print(i, end = " ")

1. a a a a a a

2. a

3.no output

4. error

Posted Date:-2021-12-30 03:05:43


Question:
What will be the output of the following Python code?

x = "abcdef"
i = "i"
while i in x:
    print(i, end=" ")

1. no output

2. i i i i i i …

3. a b c d e f

4.abcdef

Posted Date:-2021-12-30 03:03:08


Question:
What will be the output of the following Python code?

x = "abcdef"
while i in x:
    print(i, end=" ")

1.a b c d e f

2.abcdef

3. i i i i i i …

4.error

Posted Date:-2021-12-30 03:02:42


Question:
What will be the output of the following Python code?

x = 123
for i in x:
    print(i)

1.1 2 3

2.123

3.error

4.none of the mentioned

Posted Date:-2021-12-30 06:43:33


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!