Problem Solving Python

profilekhl5395
lab.doc

Problem Solving Concepts with Python

Lab 7A & 7B Menu Driven Selection & Text Processing (100 pts.) -- due the end of week 11

Textbook Problem # 4 – page 473 (Programming Logic and Design, Tony Gaddis)

Create an application that displays the following menu:

image1.png

image2.png

Select a Planet

1. Mercury

2. Venus

3. Earth

4. Mars

5. Exit the program

Enter your selection.

When the user selects a planet from the menu, the program should display data about the planet’s average distance from the sun, the planet’s mass, and the planet’s surface temperature. Use the following data in your program.

Mercury

Average distance from the sun 57.9 million kilometers

Mass 3.31 x 10∧23 kg

Surface temperature -173 to 430 degrees Celsius

Venus

Average distance from the sun 108.2 million kilometers

Mass 4.87 x 10∧24 kg

Surface temperature 472 degrees Celsius

Earth

Average distance from the sun 149.2 million kilometers

Mass 5.967 x 10∧24 kg

Surface temperature -50 to 50 degrees Celsius

Mars

Average distance from the sun 227.9 million kilometers

Mass 0.6424 x 10∧24 kg

Surface temperature -140 to 20 degrees Celsius

Menu Driven Selection: if-elif or if-else, include input validation loop

Objectives:

1. Create a Python application that utilizes menu driven selection to provide the user with menu selections related to planets, and planet information.

2. Write the out the pseudo code needed to solve this problem.

3. Solve the problem through a Python programming solution.

a. Include the use of a decision structure. if-elif or if-else

b. Refer to chapter 11 in the Python 3 Programming Companion

c. Copy and paste the output at the end of the program code.

i. Use triple quotes to indicate multi-line comment.

· (15 pts.) – Pseudo code – Astronomy Helper

a. Write the pseudo code to solve the problem.

· (35 pts.) – Python Program: Astronomy Helper

· Use IDLE, MS Visual Studio 2013 or Eclipse for Python 3.4.1.

· Write the Python source code based on your pseudo code.

#=============================================================

# Course-Lab: CS104 -- Lab-07A – Astronomy Helper

# Filename: Lab7A_AstronomyHelper.py

# Author: <Your name>

# Purpose: <Write out your own purpose for lab 7A. >

#=============================================================

Deliverable(s): Lab7A– Astronomy Helper

· Hand in the printed Python source code for Lab7A listed above.

· Test the program three times.

· Include the outputs from running the code by pasting into the source code.

· Use triple sets of quotes around the output.

· Hand in the printed hierarchy chart, and pseudo code for Lab7A.

· Submit electronic versions of the lab files.

· Pseudo code

· .py file

Lab 7B – Alphabetic Telephone Number Translator

Textbook Problem # 6 – page 495 (Programming Logic and Design, Tony Gaddis)

image3.png

Many companies use telephone numbers like 555-GET-FOOD so the number is easier for their customers to remember. On a standard telephone, the alphabetic letters are mapped to numbers in the following fashion:

A, B, and C = 2

D, E, and F = 3

G, H, and I = 4

J, K, and L = 5

M, N, and O = 6

P, Q, R, and S = 7

T, U, and V = 8

W, X, and Z = 9

Design a program that asks users to enter a 10-character telephone number in the format XXX-XXX-XXXX. The program should display the telephone number with any alphabetic characters that appeared in the original translated to their numeric equivalent. For example, if the user enters 555-GET-FOOD the program should display 555-438-3663.

Objectives:

1. Create a Python application that utilizes text processing. Refer to chapter 12.

2. Write the pseudo-code for this problem.

3. Solve the problem through a Python programming solution.

a. Refer to the Python 3 Language Companion for the Gaddis textbook.

b. Refer to the example on calculating running totals in chapter 5, section 5.4

c. Copy the output at the end of the program code. Use triple quotes to indicate multi-line comment.

· (15 pts.) – Pseudo Code – Alphabetic Telephone Number Translator

a. Write the pseudo code to solve this problem.

· (35 pts.) – Python Program: Alphabetic Telephone Number Translator

a. Use IDLE, MS Visual Studio 2013 or Eclipse for Python 3.4.1.

b. Write the Python source code based on your pseudo code.

#=============================================================

# Course-Lab: CS104 -- Lab-07B – Alphabetic Number Translator

# Filename: Lab7B_AlphabeticNumberTranslator.py

# Author: <Your name>

# Purpose: <Write out your own purpose for lab 7B>

#=============================================================

Deliverable(s): Lab7B – Alphabetic Telephone Number Translator

· Hand in the printed Python source code for Lab7B listed above.

· Test the program three times.

· Include the outputs from running the code by pasting into the source code.

· Use triple sets of quotes around the output.

· Hand in the printed flow chart, and pseudo code for Lab7B.

· Submit electronic versions of the lab files.

· Pseudo code

· .py file

1