Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(Q 1)Write a function called calculate_case that takes a string as input, and calculates the number of uppercase and lowercase letters. It should also calculate

(Q 1)Write a function called calculate_case that takes a string as input, and calculates the number of uppercase and lowercase letters. It should also calculate the total number of letters overall. The function should return these in a dictionary that looks like:

{'num_uppercase': 10, ### replace this 'num_lowercase': 10 ### replace this 'num_letters': 20 ### replace this

(But where 10 is replaced by whatever the correct number is.)

Hint: The function isalpha() can be used to determine whether a given character is a letter; recall that isupper and islower calculate whether something is uppercase or lowercase.

(Q. 2) Write a function called is_palindrome that takes a str as input, and returns True or False depending on whether the input is a palindrome.

A palindrome is a word that is spelled the same forwards or backwards. For example, the words "kayak" and "refer" are both palindromes, but "table" is not.

Hint: To solve this problem, think about how you would determine if something is a palindrome.

Start with the first and last character, and ask: are they the same?

Then move to the second and second-to-last character, and ask: are they the same?

And so on.

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

Database Principles Programming And Performance

Authors: Patrick O'Neil, Elizabeth O'Neil

2nd Edition

1558605800, 978-1558605800

More Books

Students also viewed these Databases questions

Question

3. Why might inflation be inertial?

Answered: 1 week ago