Question: In Python 3 1. Write a program that can report the number of times a certain letter appears in a string. Prompt the user for

In Python 3

1. Write a program that can report the number of times a certain letter appears in a string. Prompt the user for the string and the letter to search for and display the number of times that letter appears. Save your program in a file named letter_count.py.

2. Write a program that reads a file containing a list of numbers and displays the sum. Save your program in a file named sum_list.py.

3. Write definitions for the following two functions: sum_n(n) returns the sum of the first n natural numbers. sum_n_cubes(n) returns the sum of the cubes of the first n natural numbers. Then use these functions in a program that prompts the user for an n and prints the results of calling sum_n and sum_n_cubes, passing n to them. Save your program in a file named sums.py

4. A Caesar cipher is a simple substitution cipher based on the idea of shifting each letter of the plaintext message a fixed number (called the key) of positions in the alphabet. For example, if the key is 2, the word cat would be encoded as ecv and the word Sourpuss would be encoded as Uqwtrwuu. The original message can be recovered by reencoding the ciphertext using the negative of the key. A good Caesar cipher handles the shifts the plaintext in a circular fashion where the next character after z is a. Your program should behave in this manner. Hint: Pythons built-in ord() and chr() functions may prove handy, as well as a little modulo math. You can assume the plaintext will consist only of upper- and lower-case letters and punctuation.

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!