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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!