Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Today we are going to play with strings! This practice will help you tackle problems on your assignment. First, take a look at the Python

Today we are going to play with strings! This practice will help you tackle problems on your assignment. First, take a look at the Python file below.

The characters in a string begin from position 0. If we want to find the nth letter of a string, we are interested in the character within the string that resides at index n-1.

Suppose we had a variable name that is initialized to "Angela". The length of that string is 6, but there is NO character at position 6. You can find the character "A" at position 0 within the variable by returning name[0]. The last letter, character "a" is found at position 5 within the variable by returning name[5]. (Note that position 5 is the length of the string minues 1)

The program has already been started for you! A string variable named string has been initialized. You are going to create 4 new variables (length, letter7, and lastLetter) all based off of the string string.

Do not worry about outputting these variables. You will see that this has already been done for you.

You will write the rest of the program called pod.py to the left between the comments:

#=============================# # PLEASE START YOUR WORK HERE # #=============================# 

and

#=============================# # PLEASE END YOUR WORK HERE # #=============================# 

Nothing else should need to be changed. Details of what you should try to accomplish are below. Good luck!

Details

Input

The program reads in the following:

a string (string) of length 7 or greater (think about why this might be specified as you read along!)

Processing

This is your task!

Declare and initialize the following three variables with the names given below:

length

an integer variable

initialized to the length of string

letter7

a character variable

initialized to the 7th character of string (Remember: The first character of a string is in position 0)

lastLetter

a string variable

initialized to the last character of string

Output

Relax! The output is taken care of for you!

You will see in the code (below the comment # PLEASE END YOUR WORK HERE) that the program outputs the following details:

value of length

value of letter7

value of lastLetter

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

Database Design Using Entity Relationship Diagrams

Authors: Sikha Saha Bagui, Richard Walsh Earp

3rd Edition

103201718X, 978-1032017181

More Books

Students also viewed these Databases questions

Question

How does selection differ from recruitment ?

Answered: 1 week ago

Question

6. Does your speech have a clear and logical structure?

Answered: 1 week ago