Logo

Python Questions Set 39:

Quiz Mode

Which function is used to return JSON in Flask?

1
2
3
4

Solution:

 Which of the following data structures is returned by the functions globals() and locals()? 

1
2
3
4

Solution:

s1={1,2,3,4,5}

s2={1,2,6,8,9}

print((s1|s2)-(s1&s2))


Which of the following is same as the above code

1
2
3
4

Solution:

 

What will be the output of the following Python code if the system date is 18th June, 2017 (Sunday)?

tday=datetime.date.today()
print(tday.weekday())

1
2
3
4

Solution:

What will be the output of the following Python code?

>>> a={5,6,7,8}
>>> b={7,8,9,10}
>>> len(a+b)

1
2
3
4

Solution:

 

import time
t=(2010, 9, 20, 8, 45, 12, 6, 0, 0)
time.asctime(t)

1
2
3
4

Solution:

What will be the output of the following code?

x = "abekus".upper()
y = "ABEKUS".upper()
if (x == "ABEKUS" or y == "ABEKUS"):
print("WELCOME")
else:
print("HELLO")

1
2
3
4

Solution:

capitalize() method is used to 

1
2
3
4

Solution:

What is the output of print(k) in the following Python code snippet?

k = [print(i) for i in my_string if i not in "aeiou"]
print(k)

1
2
3
4

Solution:

What is the output of the following Python code?

class Book:
  def __init__(self,pages,color):
     self.pages=pages
     self.color=color
  def total(self):
     return self.pages
class chapter:
  def __init__(self,name,pages,color):
     self.name=name
     self.obj_book=Book(pages,color)
  def totalpages(self):
     return self.obj_book.total()
ch1=chapter('helper',20,'blue')
print(ch1.totalpages())

1
2
3
4

Solution: