Question
In Assignment 1 you wrote a Python program that circularly shifted a string by n positions. Consider a string s that is a circularly shifted
In Assignment 1 you wrote a Python program that circularly shifted a string by n positions. Consider a string s that is a circularly shifted version of the letters of the alphabet 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
s | n (number of positions shifted from 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' |
ABCDEFGHIJKLMNOPQRSTUVWXYZ | 0 |
BCDEFGHIJKLMNOPQRSTUVWXYZA | 1 |
CDEFGHIJKLMNOPQRSTUVWXYZAB | 2 |
DEFGHIJKLMNOPQRSTUVWXYZABC | 3 |
EFGHIJKLMNOPQRSTUVWXYZABCD | 4 |
and so on up to 25 |
In the module question1.py, write a function get_n(s) that has as input a string s that is a circularly shifted version of the letters of the alphabet 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' and returns the number of positions that the string is shifted by (i.e., given a string from the left column of the table above, the function returns the value in the right column).
There are several different ways to solve this problem, but the most obvious is to find the index of the 'A' in the string which Assignment 1 showed you how to do.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started