Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Get the user input and create a thematic list of strings. The program should ask for specific input theme. For example: name of the planets

Get the user input and create a thematic list of strings. The program should ask for specific input theme. For example: name of the planets in the solar system, name of your favourite vegetables, list of programming languages you hope to learn, etc. The user should enter strings for the list until a condition is met such as entering a specific word or character. There should not be hard code list size.

Each user input should be one list element.

Then process the list as follows:

4) Count and display a list of the length of each element in the list with a relevant message.

5) Use the random function to generate a random number between 0 and the maximum length of the list. This number will be used as an index to the list elements. The following code generates a random integer between 1 and 10.

Import random

print(random.randint(1, 10))

6) Have the user enter a character of their choice and check if the character exists in the string with the index number just generated at random.

7) For example:

a) The list is [Mars, Venus, Earth, Saturn, Pluto]

b) The index number generated at random is 3

c) The user enters character A

d) The program checks to see if A is in the list element with the index of 3.

e) The program should display a relevant message if the character is found in the string.

The search for the character should return true regardless if the user enters a lowercase a or an uppercase A . If the letter exists in the string either in uppercase or lowercase, the search should return true and a relevant message should be displayed.

Requirements description:

.1 Get the user input and create a thematic list of strings. The program should ask for specific input theme. For example: name of the planets in the solar system, name of your favourite vegetables, list of programming languages you hope to learn, etc. The user should enter strings for the list until a condition is met such as entering a specific word or character. There should not be hard code list size. Each user input should be one list element.

2. Then process the list as follows:

a. Count and display a list of the length of each element in the list with a relevant message.

b. Use the random function to generate a random number between 0 and the maximum length of the list. This number will be used as an index to the list elements. The following code generates a random integer between 1 and 10.

Import random print(random.randint(1, 10))

c. Have the user enter a character of their choice and check if the character exists in the string with the index number just generated at random.

d. The search for the character should return true regardless if the user enters a lowercase a or an uppercase A . If the letter exists in the string either in uppercase or lowercase, the search should return true and a relevant message should be displayed.

For example: The list is [Mars, Venus, Earth, Saturn, Pluto] The index number generated at random is 3 The user enters character A The program checks to see if A is in the list element with the index of 3. The program should display a relevant message if the character is found in the string.

******************************************************************************************************************

language is python, thanks

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

Professional SQL Server 2000 Database Design

Authors: Louis Davidson

1st Edition

1861004761, 978-1861004765

More Books

Students also viewed these Databases questions

Question

What qualities do you see as necessary for your line of work?

Answered: 1 week ago