DEV Community

Durga Pokharel
Durga Pokharel

Posted on

2 2

Day 66 Of 100DaysOfCode: Boolean Operators With Numpy

Today is my 66th day of #100daysofcode and #python learning. Today also continue to learned from Datacamp including the topic histogram customization using matplotlib, DataFrame from dictionary using pandas, comparison operator, boolean Operators with numpy.
Here is the code for boolean operator with numpy.

Code

We all are familiar with boolean operators with early days of school. Operators and, or, and not are known as boolean operator. In numpy we can use these operator as np.logical_and(), np.logical_or() and np.logical_not()

import numpy as np
my_house = np.array([18.0, 20.0, 10.75, 9.50])
your_house = np.array([14.0, 24.0, 14.25, 9.0])

# my_house greater than 18.5 or smaller than 10
print(np.logical_or(my_house > 18.5, my_house < 10))

# Both my_house and your_house smaller than 11
print(np.logical_and(my_house < 11, your_house < 11))
Enter fullscreen mode Exit fullscreen mode

Day 66 Of #100DaysOfCode and #Python
Boolean operators with Numpy From https://t.co/5PqrwUYvCBDataCamp#womenintech #100DaysOfCode #CodeNewbie #DEVCommunity #beginner pic.twitter.com/TU9m891ZPx

— Durga Pokharel (@mathdurga) March 4, 2021

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay