• The AI Problems, The Underlying Assumption, What Is An AI Techniques, The Level Of The Model, Criteria For Success...
  • Defining The Problems As A State Space Search, Production Systems, Production Characteristics, Production System Characteristics...
  • Overview, MiniMax, Alpha-Beta Cut-off, Refinements, Iterative deepening, The Blocks World, Components Of A Planning System....

Thursday, 30 July 2020

PYTHON GTU MCQ (CH-3 Python Strings)

PYTHON 
[SUBJECT CODE: 2180711]
CH-3 PYTHON STRINGS


Topics Covers:-

  • Strings and Input
  • Strings
  • Tuples
  • Lists and Dictionaries
MCQ:-

1.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

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

3.print(0xA + 0xB + 0xC):
a) 0xA0xB0xC
b) Error
c) 0x22
d) 33

 4.What will be the output of the following Python code?

1. class father:
2.     def __init__(self, param):
3.         self.o1 = param
4.  
5. class child(father):
6.     def __init__(self, param):
7.         self.o2 = param
8.  
9. >>>obj = child(22)
10. >>>print "%d %d" % (obj.o1, obj.o2)

a) None None
b) None 22
c) 22 None
d) Error is generated

 5.What will be the output of the following Python code?

1. >>>example = "helle"
2. >>>example.rfind("e")

a) -1
b) 4
c) 3
d) 1

6.To concatenate two strings to a third what statements are applicable?
a) s3 = s1 . s2
b) s3 = s1.add(s2)
c) s3 = s1.__add__(s2)
d) s3 = s1 * s2

7.Which of the following statement prints hello\example\test.txt?
a) print(“hello\example\test.txt”)
b) print(“hello\\example\\test.txt”)
c) print(“hello\”example\”test.txt”)
d) print(“hello”\example”\test.txt”)

8.Suppose s is “\t\tWorld\n”, what is s.strip()?
a) \t\tWorld\n
b) \t\tWorld\n
c) \t\tWORLD\n
d) World

9.The format function, when applied on a string returns ___________
a) Error
b) int
c) bool
d) str

10.What will be the output of the “hello” +1+2+3?
a) hello123
b) hello
c) Error
d) hello6

11.What will be the output of the “hello” +1+2+3?
a) hello123
b) hello
c) Error
d) hello6

12.To return the length of string s what command do we execute?
a) s.__len__()
b) len(s)
c) size(s)
d) s.size()

13.If a class defines the __str__(self) method, for an object obj for the class, you can use which command to invoke the __str__ method.
a) obj.__str__()
b) str(obj)
c) print obj
d) all of the mentioned

14.To check whether string s1 contains another string s2, use ________
a) s1.__contains__(s2)
b) s2 in s1
c) s1.contains(s2)
d) si.in(s2)

 15.What will be the output of the following Python code?

1. class Count:
2.     def __init__(self, count = 0):
3.     self.__count = count
4.  
5. c1 = Count(2)
6. c2 = Count(2)
7. print(id(c1) == id(c2), end = " ")  
9. s1 = "Good"
10.s2 = "Good"
11.print(id(s1) == id(s2))
\

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

16.What will be the output of the following Python code?

1. class Name:
2.     def __init__(self, firstName, mi, lastName):
3.         self.firstName = firstName
4.         self.mi = mi
5.         self.lastName = lastName
7. firstName = "John"
8. name = Name(firstName, 'F', "Smith")
9. firstName = "Peter"
10.name.lastName = "Pan"
11.print(name.firstName, name.lastName)

a) Peter Pan
b) John Pan
c) Peter Smith
d) John Smith

17.What function do you use to read a string?
a) input(“Enter a string”)
b) eval(input(“Enter a string”))
c) enter(“Enter a string”)

d) eval(enter(“Enter a string”))

18.What will be the output of the following Python code?

print('*', "abcdef".center(7), '*')

a) * abcdef *
b) * abcdef *
c) *abcdef *
d) * abcdef*

19.What will be the output of the following Python code?

print('*', "abcde".center(6), '*', sep='')

a) * abcde *
b) * abcde *
c) *abcde *
d) * abcde*

20.What will be the output of the following Python code?

print("abcdef".center(7, '1'))

a) 1abcdef
b) abcdef1
c) abcdef
d) error

 21.What will be the output of the following Python code?

print("abcdef".center(10, '12'))

a) 12abcdef12
b) abcdef1212
c) 1212abcdef
d) error

22.What will be displayed by print(ord(‘b’) – ord(‘a’))?
a) 0
b) 1
c) -1
d) 2

23.What will be the output of the following Python code?

1. >>>print("D", end = ' ')
2. >>>print("C", end = ' ')
3. >>>print("B", end = ' ')
4. >>>print("A", end = ' ')

a) DCBA
b) A, B, C, D
c) D C B A
d) D, C, B, A will be displayed on four lines

24.What will be the output of the following Python code?

1. >>>example="helloworld"
2. >>>example[::-1].startswith("d")

a) dlrowolleh
b) True
c) -1
d) None

 25.What will be the output of the following Python code?

1. >>>example = "helle"
2. >>>example.find("e")

a) Error
b) -1
c) 1
d) 0



More MCQ Uploading Soon... Stay Tune
Comment Your View In Below Section.. it's Very Helpful...

Wednesday, 29 July 2020

PYTHON GTU MCQ (CH-2 Python Loops)

PYTHON 
[SUBJECT CODE: 2180711]
CH-2 LOOPS


Topics Covers:-

  • Functions and scoping 
  • Specifications 
  • Recursion 
  • Global variables 
  • Modules
  • Files 
  • System Functions and Parameters
  • loops
MCQ:-

1.What will be the output of the following Python code?

i =1

while True:

    if i%7 ==0O7:

        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

2.What will be the output of the following Python code?

i =5

whileTrue:

    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

3.What will be the output of the following Python code?

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

4.What will be the output of the following Python code?

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

5.What will be the output of the following Python code?

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

6.What will be the output of the following Python code?

True = False

while True:

    print(True)

    break

a) True
b) False
c) None
d) none of the mentioned

7.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)

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

 8.What will be the output of the following Python code?

i = 0

while i < 3:

    print(i)

    i += 1

else:

    print(0)

a) 0 1 2 3 0
b) 0 1 2 0
c) 0 1 2
d) error

9.What will be the output of the following Python code?

x = "abcdef"

i = "i"

while i in x:

    print(i,end=" ")

a)nooutput
b)iiiiii…
c)abcdef
d)abcdef

10.What will be the output of the following Python code?

x = "abcdef"

i = "a"

while i in x:

    x = x[:-1]

    print(i,end = " ")


a) i i i i i i

b) a a a a a a
c) a a a a a

d) none of the mentioned

11.What will be the output of the following Python code?

x = "abcdef"

i = "a"

while i in x:

    x = x[1:]

    print(i,end = " ")


a) a a a a a a

b) a
c) no output

d) error

12.What will be the output of the following Python code?

x = 'abcd'

for i in x:

    print(i.upper())


a) a b c d

b) A B C D
c) a B C D

d) error

13.What will be the output of the following Python code?

x = 'abcd'

for i in range(len(x)):

    print(i)


a) a b c d

b) 0 1 2 3
c) error

d) 1 2 3 4

14.What will be the output of the following Python code snippet?

x = 'abcd'

for i in range(len(x)):

    i.upper()

print(x)


a) a b c d

b) 0 1 2 3
c) error

d) none of the mentioned

15.What will be the output of the following Python code?

for i in range(2.0):

    print(i)

a) 0.0 1.0
b) 0 1
c) error
d) none of the mentioned

16.What will be the output of the following Python code?

for i in range(int(2.0)):

    print(i)

a) 0.0 1.0
b) 0 1
c) error
d) none of the mentioned

17.What will be the output of the following Python code?

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

    print(i)

a) 0.0 0.1 0.2 0.3 …
b) 0 1 2 3 …
c) 0.0 1.0 2.0 3.0 …
d) none of the mentioned

18.What will be the output of the following Python code snippet?

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

    print (i)

a) a b c d
b) d c b a
c) error
d) none of the mentioned

19.What will be the output of the following Python code snippet?

for i in 'abcd'[::-1]:

    print(i)

a) a b c d
b) d c b a
c) error
d) none of the mentioned

20.What will be the output of the following Python code snippet?

x = 2

for i in range(x):

    x += 1

    print(x)

a) 0 1 2 3 4 …
b) 0 1
c) 3 4
d) 0 1 2 3

21.What will be the output of the following Python code snippet?

x = 2

for i in range(x):

    x -= 2

    print(x)

a) 0 1 2 3 4 …
b) 0 -2
c) 0
d) error

22.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")

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

23.What will be the output of the following Python code?

x = (i for i in range(3))

for i in x:

    print(i)

for i in x:

    print(i)

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

24.What will be the output of the following Python code?

string = "my name is x"

for i in string:

    print(i, end=", ")

a) m, y, , n, a, m, e, , i, s, , x,
b) m, y, , n, a, m, e, , i, s, , x
c) my, name, is, x,
d) error

25.What will be the output of the following Python code snippet?

a =[0,1, 2, 3]

for a[-1] in a:

    print(a[-1])

a) 0 1 2 3
b) 0 1 2 2
c) 3 3 3 3
d) error

More MCQ Uploading Soon... Stay Tune
Comment Your View In Below Section.. it's Very Helpful...