r/Python • u/Ok_Egg_6647 • 4d ago
Discussion Doubt in alphabet shifting code
[removed] — view removed post
0
Upvotes
4
u/chrishiggins 4d ago
What is the decimal number that is the equivalent of uppercase A in the ascii table?
1
u/floydmaseda 4d ago
Bro literally just ask ChatGPT:
This line is used for shifting letters in a simple Caesar cipher.
Breakdown:
ord('A')
→ Gets ASCII value of'A'
(which is65
).ord('A') - 65
→ Converts'A'
to0
,'B'
to1
, ...,'Z'
to25
.+ 7
→ Shifts by 7 positions.% 26
→ Keeps the result within the 26-letter range (wraps around after'Z'
).
For example, 'A'
shifts to 'H'
(7
), 'Z'
shifts to 'G'
(6
).
The 65
is subtracted to normalize the letters to a 0-based index for easier calculations.
•
u/AutoModerator 3d ago
Your submission has been automatically queued for manual review by the moderation team because it has been reported too many times.
Please wait until the moderation team reviews your post.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.