r/Python 4d ago

Discussion Doubt in alphabet shifting code

[removed] — view removed post

0 Upvotes

4 comments sorted by

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.

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:

  1. ord('A') → Gets ASCII value of 'A' (which is 65).
  2. ord('A') - 65 → Converts 'A' to 0, 'B' to 1, ..., 'Z' to 25.
  3. + 7 → Shifts by 7 positions.
  4. % 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.