DEV Community

Bas Steins
Bas Steins

Posted on

4 1

A small Python Quiz

Can you guess what value the variable a has to take, so that this program prints A is not equal A!?

if a != a:
    print("A is not equal A!")
Enter fullscreen mode Exit fullscreen mode

Top comments (4)

Collapse
 
variac profile image
Variac

float('nan')

Collapse
 
mridulnetizen profile image
Euxodous

That's cool! I'm wondering what's the reason for the same? Please explain

Collapse
 
bascodes profile image
Bas Steins

Nan stands for “not a number” and comparing two things we know nothing about (other than what they’re not) is not reasonable.

Therefore by definition, nan is not the same as another nan.

Collapse
 
bascodes profile image
Bas Steins

That’s correct!

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