this post was submitted on 31 Oct 2024
48 points (96.2% liked)

Python

6368 readers
18 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

πŸ“… Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
πŸ’“ Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 1 year ago
MODERATORS
 

Note: The attached image is a screenshot of page 31 of Dr. Charles Severance's book, Python for Everybody: Exploring Data Using Python 3 (2024-01-01 Revision).


I thought = was a mathematical operator, not a logical operator; why does Python use

>= instead of >==, or <= instead of <==, or != instead of !==?

Thanks in advance for any clarification. I would have posted this in the help forums of FreeCodeCamp, but I wasn't sure if this question was too.......unspecified(?) for that domain.

Cheers!

Β 


Edit: I think I get it now! Thanks so much to everyone for helping, and @FizzyOrange@programming.dev and @itslilith@lemmy.blahaj.zone in particular! ^_^

you are viewing a single comment's thread
view the rest of the comments
[–] FizzyOrange@programming.dev 22 points 2 weeks ago (14 children)

>= and <= match the mathematical operators. The question you want to ask is why doesn't it use = for equality, and the answer is that = is already used for assignment (inherited from C among other languages).

In theory a language could use = for assignment and equality but it might be a bit confusing and error prone. Maybe not though. Someone try it and report back.

[–] EveryMuffinIsNowEncrypted@lemmy.blahaj.zone 1 points 2 weeks ago* (last edited 2 weeks ago) (9 children)

I think what I'm most confused about is I cannot for the life of me seem to wrap my head around the difference between "assignment" and "equality". They seem exactly the same to me: when a variable is assigned a value, it's equal to that value now.

Even if I were write the program

x = 20
print(x*2)

it would still print 40. Because x is equal to 20. Because it was assigned the value of 20.

Hell, I've even heard Dr. Severance say "equal to" in this context in earlier videos multiple times.

[–] rain_worl@lemmy.world 1 points 2 weeks ago (2 children)

ah, but consider: a+b=2
(perfectly valid in metafont!)

[–] EveryMuffinIsNowEncrypted@lemmy.blahaj.zone 1 points 2 weeks ago (1 children)

I apologize; I do not know what "metafont" is...

[–] rain_worl@lemmy.world 1 points 2 weeks ago

programming language; tex's sibling. you define a system of equations that it solves

load more comments (6 replies)
load more comments (10 replies)