Question

thirty is a string with 3 or more letters. Write a simple expression to return the...

thirty is a string with 3 or more letters.

Write a simple expression to return the last three characters in thirty.

Homework Answers

Answer #1

I answered this question in Python, since specific programming language is not given.

Code:

# Function to return last three characters of string
def three_char(string):
    temp = len(string)
    return string[temp-3:temp]
# Give string here
string = "thirty"
# Taking the returned value and printing it
print(three_char(string))

Code screenshot:

Output:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
3. Write function, leastChar(inputString) that takes as input a string of one or more letters (and...
3. Write function, leastChar(inputString) that takes as input a string of one or more letters (and no other characters) and prints 1) the "least" character in the string, where one character is less than another if it occurs earlier in the alphabet (thus 'a' is less than 'C' and both are less than 'y') and 2) the index of the first occurrence of that character. When comparing letters in this problem, ignore case - i.e. 'e' and 'E' should be...
Write the regular expression that will match the following string pattern descriptions. A space character at...
Write the regular expression that will match the following string pattern descriptions. A space character at the beginning of a line Upper case vowel one and more lines with a length of exactly 80 characters A single character that cannot be an alpha or a digit A dollar sign character ‘$’ at the end of the line
Question 4 Write a regular expression that generates each of the following language constructs: (1) String...
Question 4 Write a regular expression that generates each of the following language constructs: (1) String constants with the following specifications: A string constant consists of any sequence of characters enclosed by the quotation marks: “ and ”       The sequence may be empty.                    The sequence cannot span multiple lines.       Don’t worry about escape characters (assume that they won’t appear in the input).       (2)  Multiple-line comment in C, C++ and JAVA with the following specifications:        The comment consists of any sequence...
Write a regular expression that generates each of the following language constructs: (1) String constants with...
Write a regular expression that generates each of the following language constructs: (1) String constants with the following specifications: A string constant consists of any sequence of characters enclosed by the quotation marks: “ and ” The sequence may be empty.​ The sequence cannot span multiple lines. Don’t worry about escape characters (assume that they won’t appear in the input). (2) Multiple-line comment in C, C++ and JAVA with the following specifications: The comment consists of any sequence of characters...
Write python code that reads a string with numbers and letters and outputs sum of the...
Write python code that reads a string with numbers and letters and outputs sum of the numbers and number of letters.
Write a JavaScript program to create a new string from a given string changing the position...
Write a JavaScript program to create a new string from a given string changing the position of first and last characters. The string length must be greater than or equal to 1. it has to be in (HTML)
Let s be a string that contains a simple mathematical expression, e.g., s = '1.5 +...
Let s be a string that contains a simple mathematical expression, e.g., s = '1.5 + 2.1-3' s = '10.0-1.6 + 3 - 1.4' The expression will have multiple operands. We don't know exactly how many operands there are in s. The operator will be one of the following: +, -. Write a function called plus_minus() that takes s as the input, interpret the expression, then evaluate and return the output. Note: The use of the eval() is not allowed...
C++: Write a function that receives a pointer to a character string consisting of only alphabets...
C++: Write a function that receives a pointer to a character string consisting of only alphabets a-z and returns the character with the maximum number of repetitions. If more than one-character repeats same number of times, return the character with smallest alphabetical order. For example, the string “Mississippi” has three repeated characters (i-4, s-4, p-2). Both ‘i’ and ‘s’ repeated 4 times but ‘i’ is alphabetically smaller hence the function should return ‘i’. Do not count repeated blanks, special characters,...
Please write a function three(string) that return a string that all three-letter words are replaced by...
Please write a function three(string) that return a string that all three-letter words are replaced by ***.   For example: three("submit only one question per post.  ") return: "submit only *** question *** post. " Please using Python!
Write a program that prompts the user to enter a string and displays the number of...
Write a program that prompts the user to enter a string and displays the number of characters it contains, fourth character, and last character. Note: The string may contain blanks. For example: “C++ programming is fun”. You should write a complete program.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT