Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

NEED CODE IN PYTHON 4. Write a Python program stored in a file L4q4.py that:that takes a string variable as input from the user and

image text in transcribed

NEED CODE IN PYTHON

4. Write a Python program stored in a file L4q4.py that:that takes a string variable as input from the user and prints the length of the entry on the next line. If the length of the entry is even, print all the characters that are in the even position. If the length of the entry is odd, print all the characters that are in the odd position. Add an empty line. On the following line, print the index of each character under the corresponding character. Sample output #1: Print one full line of * on line 1. At the prompt, the user enters Texas A&M University (line 2). The program outputs the length of input on line 3 (even). Line 4 is blank and on line 5 all the characters in the even positions are printed. The corresponding index of each character is printed below them on line 6 and one full line of * is printed on line 7. *********** 1. ********************************************** 2. Enter a string variable: Texas A&M University 3. Length of the string Texas A&M University is 20 4. 5. T s A MU i es t 6. O 2 4 6 8 10 12 14 16 18 7. ********* ************** ************** ************************ Sample output #2: Print one full line of * on line 1. At the prompt, the user enters Howdy! Good Luck." (line 2). The program outputs the length of input on line 3 (odd). Line 4 is blank and on line 5 all the characters in even positions are printed. The corresponding index of each character is printed below them on line 6 and one full line of * is printed on line 7. 1. ************* 2. Enter a string variable: Howdy! Good Luck. 3. Length of the string Howdy! Good Luck. is 17 4. 5. 0 d ! o u k 6. 1 3 5 7 9 11 13 15 7. ****** ****************

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

Concepts Of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

4th Edition

0619064625, 978-0619064624

More Books

Students also viewed these Databases questions

Question

Define the term Working Capital Gap.

Answered: 1 week ago

Question

3. What strategies might you use?

Answered: 1 week ago