Starting Out with Python (4th Edition)
4th Edition
ISBN: 9780134444321
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 8, Problem 5AW
Write a function that accepts a string as an argument and returns true if the argument ends with the substring '.com'. Otherwise, the function should return false.
Expert Solution & Answer
Learn your wayIncludes step-by-step video
schedule04:40
Students have asked these similar questions
Write a function that accepts a string as an argument and returns true if the
argument ends with the substring .doc'. Otherwise, the function should return
false
Write a function that reverses a string. The header of the function is:
def reverse(s):Write a test program that prompts the user to enter a string, invokes the reverse function, and displays the reversed string.
Programming language: SWIFT
Write a function that takes a string as a parameter and returns the string "Swift" if the string passed as
parameter begins with "SWIFT" or "swift". Otherwise, returns an empty string.
Chapter 8 Solutions
Starting Out with Python (4th Edition)
Ch. 8.1 - Assume the variable name references a string....Ch. 8.1 - What is the index of the first character in a...Ch. 8.1 - If a string has 10 characters, what is the index...Ch. 8.1 - Prob. 4CPCh. 8.1 - Prob. 5CPCh. 8.1 - Prob. 6CPCh. 8.2 - Prob. 7CPCh. 8.2 - Prob. 8CPCh. 8.2 - Prob. 9CPCh. 8.2 - What will the following code display? mystring =...
Ch. 8.3 - Prob. 11CPCh. 8.3 - Prob. 12CPCh. 8.3 - Write an if statement that displays Digit" if the...Ch. 8.3 - What is the output of the following code? ch = 'a'...Ch. 8.3 - Write a loop that asks the user Do you want to...Ch. 8.3 - Prob. 16CPCh. 8.3 - Write a loop that counts the number of uppercase...Ch. 8.3 - Assume the following statement appears in a...Ch. 8.3 - Assume the following statement appears in a...Ch. 8 - This is the first index in a string. a. 1 b. 1 c....Ch. 8 - This is the last index in a string. a. 1 b. 99 c....Ch. 8 - This will happen if you try to use an index that...Ch. 8 - This function returns the length of a string. a....Ch. 8 - This string method returns a copy of the string...Ch. 8 - This string method returns the lowest index in the...Ch. 8 - This operator determines whether one string is...Ch. 8 - This string method returns true if a string...Ch. 8 - This string method returns true if a string...Ch. 8 - This string method returns a copy of the string...Ch. 8 - Once a string is created, it cannot be changed.Ch. 8 - You can use the for loop to iterate over the...Ch. 8 - The isupper method converts a string to all...Ch. 8 - The repetition operator () works with strings as...Ch. 8 - Prob. 5TFCh. 8 - What does the following code display? mystr =...Ch. 8 - What does the following code display? mystr =...Ch. 8 - What will the following code display? mystring =...Ch. 8 - Prob. 4SACh. 8 - What does the following code display? name = 'joe'...Ch. 8 - Assume choice references a string. The following...Ch. 8 - Write a loop that counts the number of space...Ch. 8 - Write a loop that counts the number of digits that...Ch. 8 - Write a loop that counts the number of lowercase...Ch. 8 - Write a function that accepts a string as an...Ch. 8 - Prob. 6AWCh. 8 - Write a function that accepts a string as an...Ch. 8 - Assume mystrinc references a string. Write a...Ch. 8 - Assume mystring references a string. Write a...Ch. 8 - Look at the following statement: mystring =...Ch. 8 - Initials Write a program that gets a string...Ch. 8 - Sum of Digits in a String Write a program that...Ch. 8 - Date Printer Write a program that reads a string...Ch. 8 - Prob. 4PECh. 8 - Alphabetic Telephone Number Translator Many...Ch. 8 - Average Number of Words If you have downloaded the...Ch. 8 - If you have downloaded the source code you will...Ch. 8 - Sentence Capitalizer Write a program with a...Ch. 8 - Prob. 10PECh. 8 - Prob. 11PECh. 8 - Word Separator Write a program that accepts as...Ch. 8 - Pig Latin Write a program that accepts a sentence...Ch. 8 - PowerBall Lottery To play the PowerBall lottery,...Ch. 8 - Gas Prices In the student sample program files for...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Define the term process as it is used in the context of operating systems.
Computer Science: An Overview (12th Edition)
Write a program to print the corresponding Celsius to Fahrenheit table.
C Programming Language
Under what circumstances does Java automatically provide a default constructor for a class?
Starting Out with Java: Early Objects (6th Edition)
Guess the Number Design a number guessing game program. The program should generate a random number and then as...
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Explain how each of the following types of integrity constraints is enforced in the SQL CREATE TABLE commands: ...
Modern Database Management (12th Edition)
Repeat Programming Project 11 from Chapter 10 but use an array to store the movie ratings instead of separate v...
Problem Solving with C++ (9th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Make a function is_palindrome that takes a string as an argument that returns True if the given string is a palindrome, and False otherwise. A string is a palindrome if it is the same if you reverse it. For example: "racecar" "kаyak" "otto" "redivider" "wontloversrevoltnow"arrow_forward// Write a function that takes 1 argument, a string. // It returns true if the string is a palindrome (the same forwards and backwards). // It returns false if the string is not a palindrome. const isPalindrome = (string) => { // your code here... // Examples isPalindrome("cat") // returns false //isPalindrome("level") // returns true }arrow_forwardWrite a function that searches for a particular character in a string using the following header: void search(string& s, char& key) Write a test program that prompts the user to enter the string and a character and displays if the character is found.arrow_forward
- 4. What is the value returned by function compareTo() if the invoking string is less than the string compared? a) zero b) value less than zero c) value greater than zero d) none of the mentionedarrow_forwardIn C language, Write a function that gets a string containing a positive integer. The function subtracts 1 fromthat integer and puts the obtained value in the string. void str_subtract_one(char* num); For example:- if before we call str_subtract_one(str) we have str==“1997”, then after return str will be “1996”.- if before we call str_subtract_one(str) we have str==“12345678987650”, then after return str will be “12345678987649”.- if before we call str_subtract_one(str) we have str==“100”, then after return str will be “99”. 1. You may assume that the input is always legal, i.e., the string is a positive integer correctly formatted.2. Note that the numbers may be larger than the maximum of int or long. That is, you should not try to convert string to intarrow_forward4. Complete the function show_upper. This function takes one parameter - a string (s). It should return a string made up of all the upper-case characters in s. For example, if s is “aBdDEfgHijK” then show_upper should return “BDEHK”. It should return the upper-case string - not print it. Do not change anything outside show_upper.arrow_forward
- C++ code please Write a program that uses the function isPalindrome . Test your program on the following strings: madam, abba, 22, 67876, 444244, trymeuemyrt Modify the function isPalindrome so that when determining whether a string is a palindrome, cases are ignored, that is, uppercase and lowercase letters are considered the same. Your program should print a message indicating if a string is a palindrome: madam is a palindrome Use expressions: .+*isPalindrome\(\"Madam\"\).+* .+*isPalindrome\(\"abBa\"\).+* .+*isPalindrome\(\"22\"\).+* .+*isPalindrome\(\"67876\"\).+* .+*isPalindrome\(\"444244\"\).+* .+*isPalindrome\(\"trYmeuemyRT\"\).+* in the code.arrow_forwardJS Write a function named "tweets" that takes a string as a parameter. If a message can hold at most 280 characters, calculate the smallest number of messages needed to hold all of the text in the input. The function should return the number it calculated.arrow_forwardUsing C++ write this code Write a function called isValidNote that accepts a string and returns true if that string is a valid note expressed in SPN and false otherwise. See the explanation above for clarity on what is and is not considered valid SPN. Function Specifications: Name: isValidNote() Parameters (Your function should accept these parameters IN THIS ORDER): note (string): The string to be checked Return Value: True or false (bool) The function should return true if the string is a valid note in SPN and false otherwise. The function should not print anything. The function should be case-sensitive, e.g. B0 is valid SPN but b0 is not. Hint: Any note expressed in valid SPN will be exactly 2 characters long. --- Examples --- Sample function call Expected return value isValidNote("y") False isValidNote("D4") True isValidNote("d4") False isValidNote("E72") False isValidNote("I love coding") False Your file should be named isValidNote.cpp and should also…arrow_forward
- 5. A prime number is a number that is only evenly divisible by itself and 1. For example, the number 5 is prime because it can only be evenly divided by 1 and 5. The number 6, how- ever, is not prime because it can be divided evenly by 1, 2, 3, and 6. Write a Boolean function named is_prime which takes an integer as an argument and returns true if the argument is a prime number, or false otherwise. Use the function in a program that prompts the user to enter a number then displays a message indicating whether the number is prime. 6. In another program, use the function you wrote in question 5 to print the prime numbers between 1 and 100 using for loop.arrow_forwardWrite a function that returns the common characters of two strings using the following header: string commonChars(const string& s1, const string& s2) Write a test program that prompts the user to enter two strings and display their common characters. Here are some sample runs:arrow_forwardWrite the following function to check whether a string is a palindrome assuming letters are case-insensitive: bool isPalindrome(const string& s) Write a test program that reads a string and displays whether it is a palindrome.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
What Are Data Types?; Author: Jabrils;https://www.youtube.com/watch?v=A37-3lflh8I;License: Standard YouTube License, CC-BY
Data Types; Author: CS50;https://www.youtube.com/watch?v=Fc9htmvVZ9U;License: Standard Youtube License