Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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_2

Step: 3

blur-text-image_3

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

Relational Database Design With Microcomputer Applications

Authors: Glenn A. Jackson

1st Edition

0137718411, 978-0137718412

More Books

Students also viewed these Databases questions

Question

How autonomous should the target be left after the merger deal?

Answered: 1 week ago

Question

fscanf retums a special value EOF that stands for...

Answered: 1 week ago