My Report

Python Operators Test – 3


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. Which of the following Boolean expressions is not logically equivalent to the other three?

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

class Truth:
	pass
x=Truth()
bool(x)

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

not(10<20) and not(10>30)

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

not(3>4)
not(1&1)

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

['hello', 'morning'][bool('')]

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

l=[1, 0, 2, 0, 'hello', '', []]
list(filter(bool, l))

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

if (9 < 0) and (0 < -9):
    print("hello")
elif (9 > 0) or False:
    print("good")
else:
    print("bad")

8. What will be the output of the following Python code if the system date is 21st June, 2017 (Wednesday)?

[] or {}
{} or []

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

['f', 't'][bool('spam')]

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

bool(‘False’)
bool()

 

Start practicing “1000 MCQs on Python”, and once you are ready, you can take tests on all topics by attempting our “Python Test Series”.

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.