Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python3 Write a rotate() function that takes a string intended to be one upper-case A-Z letter and an integer as inputs and returns a string.

Python3

Write a rotate() function that takes a string intended to be one upper-case A-Z letter and an integer as inputs and returns a string. *The returned string should be the *input letter rotated by the number of positions specified by the integer argument*. (The Romans of Caesar's time only used what today we call upper-case letters.)

So a call to rotate("C", 1) should return (return not print) the string D and a call to rotate(D, -1) should return the string "C". Rotation should "wrap around" the end of the alphabet, so rotate("Z", 3) should return "C".

Hints:

It will be useful for you to use a string containing all the upper case letters in order. You probably want to use a variable assignment for this.

And indexing of strings

You will want to use the remainder function % together with addition (+) to the get the wrapping around the end of the alphabet behavior.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions

Question

1. Explain what is meant by ethical behavior.

Answered: 1 week ago

Question

7. How might you go about testing these assumptions?

Answered: 1 week ago