Logo

Python Questions Set 155:

Quiz Mode

Which file in a Django project contains the URLs?

1
2
3
4

Solution:

What is the output of the following code?


print(4**5., 4**5)

1
2
3
4

Solution:

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

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

"john" in d

1
2
3
4

Solution:

  Which of the following commands will create a list? 

1
2
3
4

Solution:

Which of the following is an invalid statement?

1
2
3
4

Solution:

 

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

 a={1:"A",2:"B",3:"C"}

 print(a.get(5,4)) 

1
2
3
4

Solution:

What will be the output of the following Python code?

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

1
2
3
4

Solution:

Find the output of the following code:


list = [1, 2, 3, 4, 5, 6, 7, 2]

list.pop(2)

list.pop()

print(list)

1
2
3
4

Solution:

What is the output of the following code?


a = 1

message = ""

if a:

    message += "Hello"

elif a == 1:

    message += "Hi"

else:

    message += "bye"

print(message)

1
2
3
4

Solution:

 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?

1
2
3
4

Solution: