Computer Science: An Overview (13th Edition) (What's New in Computer Science)
13th Edition
ISBN: 9780134875460
Author: Glenn Brookshear, Dennis Brylow
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 6, Problem 8CRP
Suppose f is a function that returns the result of reversing the string of symbols given as its input, and g is a function that returns the concatenation of the two strings given as its input. If x is the string abcd, what is returned by g(f(x), x)?
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a function that takes a String and checks whether or not it ends with one of "T", *?.", or *" Return true if it does, otherwise false. Try writing your solution using regular String methods and again as a RegExp
Using your solution, do a check on the following sentences:
a sentence ending with!
Write the code in python to define a function has_repeat(mystr), which takes a string parameter and returns a boolean result.
- If mystr has a character that is repeated (count is more than 1 for that character), return True
- Otherwise, return False
Hint: You can solve this problem by iterating over the characters in mystr and comparing each character's count with 1.
For example:
Test
Result
print(has_repeat("Happy"))
True
print(has_repeat("sad"))
False
print(has_repeat("salmons"))
True
print(has_repeat("Trouts"))
False
The following words have three consecutive letters that are also consecutive letters in the alphabet: THIRSTY, NOPE, AFGHANISTAN, STUDENT.
Write a program that accepts a word as input and determines whether or not it has three consecutive letters that are also consecutive letters in the alphabet.
I got help from expert for this problem. But I would like to see other solution without using len and ord functions if it possiable.
Chapter 6 Solutions
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Ch. 6.1 - In what sense is a program in a third-generation...Ch. 6.1 - We can summarize the imperative programming...Ch. 6.1 - Prob. 4QECh. 6.2 - Why is the use of a constant considered better...Ch. 6.2 - Prob. 2QECh. 6.2 - Prob. 3QECh. 6.2 - Identity some common control structures found in...Ch. 6.2 - What is the difference between an array and an...Ch. 6.3 - Prob. 1QECh. 6.3 - Prob. 2QE
Ch. 6.3 - Why do many programming languages implement I/O...Ch. 6.3 - Prob. 4QECh. 6.3 - Prob. 5QECh. 6.4 - Prob. 1QECh. 6.4 - What is a symbol table?Ch. 6.4 - What is the difference between a terminal and a...Ch. 6.4 - Prob. 4QECh. 6.4 - Prob. 5QECh. 6.4 - Prob. 6QECh. 6.5 - What is the difference between an object and a...Ch. 6.5 - Prob. 2QECh. 6.5 - Suppose the classes PartTimeEmployee and...Ch. 6.5 - What is a constructor?Ch. 6.5 - Why are some items within a class designated as...Ch. 6.6 - Prob. 1QECh. 6.6 - Prob. 2QECh. 6.6 - Prob. 3QECh. 6.7 - Prob. 2QECh. 6.7 - Prob. 3QECh. 6.7 - Prob. 4QECh. 6 - Prob. 1CRPCh. 6 - Translate the following Python program into the...Ch. 6 - Prob. 3CRPCh. 6 - Why was it necessary to identify the type of data...Ch. 6 - Prob. 6CRPCh. 6 - Suppose the function f expects two numeric values...Ch. 6 - Suppose f is a function that returns the result of...Ch. 6 - Prob. 9CRPCh. 6 - Summarize the distinction between a machine...Ch. 6 - John Programmer argues that the ability to declare...Ch. 6 - Summarize the distinction between declarative...Ch. 6 - Explain the differences between a literal, a...Ch. 6 - a. What is operator precedence? b. Depending on...Ch. 6 - Prob. 16CRPCh. 6 - What is the difference between the meaning of the...Ch. 6 - Draw a flowchart representing the structure...Ch. 6 - Prob. 19CRPCh. 6 - Prob. 20CRPCh. 6 - Draw a flowchart representing the structure...Ch. 6 - Rewrite the following program segment using a...Ch. 6 - Summarize the following rats-nest routine with a...Ch. 6 - Prob. 24CRPCh. 6 - Prob. 25CRPCh. 6 - Suppose the variable X in a program was declared...Ch. 6 - Prob. 27CRPCh. 6 - Why would a large array probably not be passed to...Ch. 6 - Sometimes an actual parameter is passed to a...Ch. 6 - Prob. 32CRPCh. 6 - What ambiguity exists in the statement X = 3 + 2 ...Ch. 6 - Suppose a small company has five employees and is...Ch. 6 - Prob. 35CRPCh. 6 - Prob. 36CRPCh. 6 - Prob. 37CRPCh. 6 - Prob. 38CRPCh. 6 - Prob. 39CRPCh. 6 - Design a set of syntax diagrams that describes the...Ch. 6 - Prob. 41CRPCh. 6 - Prob. 42CRPCh. 6 - Add syntax diagrams to those in Question 5 of...Ch. 6 - Prob. 44CRPCh. 6 - What code optimization could be performed by a...Ch. 6 - Simplify the following program segment Y = 5 if (Y...Ch. 6 - Simplify the following program segment while (X !=...Ch. 6 - In an object-oriented programming environment, how...Ch. 6 - Describe how inheritance might be used to develop...Ch. 6 - What is the difference between the public and...Ch. 6 - a. Give an example of a situation in which an...Ch. 6 - Describe some objects that might be found in a...Ch. 6 - Prob. 53CRPCh. 6 - Prob. 54CRPCh. 6 - Prob. 55CRPCh. 6 - Prob. 56CRPCh. 6 - Prob. 57CRPCh. 6 - Prob. 58CRPCh. 6 - Prob. 59CRPCh. 6 - In general copyright laws support ownership rights...Ch. 6 - By using a high-level programming language, a...Ch. 6 - Prob. 3SICh. 6 - Prob. 4SICh. 6 - Prob. 5SICh. 6 - Suppose an amateur programmer writes a program for...Ch. 6 - Prob. 7SI
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
The following perfectly valid C program was written without much attention paid to its format. As you will obse...
Programming in C
T F The base class constructor is called after the derived class constructor.
Starting Out with C++ from Control Structures to Objects (8th Edition)
What is the general problem with static scoping?
Concepts of Programming Languages (11th Edition)
Assume the following statement appears in a program: days = 'Monday Tuesday Wednesday'
Starting Out with Python (4th Edition)
What is a source program?
Absolute Java (6th Edition)
What two questions should you ask to determine a classs responsibilities?
Starting Out with Java: From Control Structures through Data Structures (3rd 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
- please code in python MCQ are a very popular form of assessment because they can be automatically graded…and the students can choose an answer at random if they don’t know.The goal of this exercise is to write a function scoreMCQ(attempt, correct), where attempt is a string that contains the answers of the student and correct is a string with the correct answers.The function should return the number of correct answers.Check first that both strings have the same length, otherwise raise an exception.If both strings are empty the score should be 0 of course.To test your code, you can copy paste the following assert statements as your main function:assert(scoreMCQ("","")==0), "First test failed"assert(scoreMCQ("TFTF","TTTT")==2), "Second test failed"assert(scoreMCQ("TTTT","TTTT")==4), "Third test failed"assert(scoreMCQ("CCCC","ABCD")==1), "Fourth test failed"print("All tests succesfull")arrow_forwarduestion 42: Return whether a string consists of a single letter In the function below, return True if the input string parameter consists of a single uppercase letter; otherwise, return False. Most solutions would do this in two logical steps: first testing if the string consists of a single character and, second, testing whether that character is one of the uppercase letters (which can be done by seeing if it is alphabetically between A and Z, inclusive).arrow_forwardTwo words are anagrams if they are formed by rearranging the letters of another, such as cinema, formed from iceman, and vice versa. Implement an anagram checker function using string functions in C. Your program should be able to: 1. Scan for the two words to be checked 2. Pass those two words to a function called areAnagrams which returns an int to be interpreted in the main() whether the given words are anagrams or not. 3. The program should loop indefinitely until the words "EXIT NOW" is used as input. Sample Run: Enter two strings: cinema iceman cinema and iceman are anagrams! Enter two strings: almost atoms almost and atoms are NOT anagrams Enter two strings: vice versa vice and versa are NOT anagrams! Enter two strings: frail flare frail and flare are NOT anagrams! Enter two strings: algorithm logarithm algorithm and logarithm are anagrams! Enter two strings: EXIT NOWarrow_forward
- Write a function that determines if two strings are anagrams. The functionshould not be case sensitive and should disregard any punctuation or spaces.Two strings are anagrams if the letters can be rearranged to form each other.For example, “Eleven plus two” is an anagram of “Twelve plus one”. Each stringcontains one “v”, three “e’s”, two “l’s”, etc. Test your function with severalstrings that are anagrams and non-anagrams. You may use either the string classor a C-style string. use c++arrow_forwardIn Kotlin A. Write a function lengthGreaterThan() with an expression body that takes a String s and an Int n and returns true if the String is at least n characters long. Then revise the function so that it can accept null values. If it receives null as the parameter, it should return false. B. Write a recursive function with an expression body that takes a list of nullable Strings and and Int an returns a list of just the Strings from the original list for which the function you wrote in the first part returns true C. Get the same result as in part B by using filter()arrow_forwardBartleby answered my homework and Write a function called has_duplicates that takes a string parameter and returns True if the string has any repeated characters. Otherwise, it should return False. Implement has_duplicates by creating a histogram using the histogram function above. Do not use any of the implementations of has_duplicates that are given in your textbook. Instead, your implementation should use the counts in the histogram to decide if there are any duplicates. Write a loop over the strings in the provided test_dups list. Print each string in the list and whether or not it has any duplicates based on the return value of has_duplicates for that string. For example, the output for "aaa" and "abc" would be the following. aaa has duplicatesabc has no duplicates Print a line like one of the above for each of the strings in test_dups. True needs to be defined. I tried to code it but didn't accept and got an error message.arrow_forward
- Write a function vowelIndex that accepts a word (a str ) as an argument and returns the indexof the first vowel in the word. If there is no vowel, -1 is returned. For this problem, both upperand lower case vowels count, and 'y' is not considered to be a vowel. #note that the language is Pythonarrow_forwardWrite the function strend (s ,t ), which returns 1 if the string t occurs at the end of the string s, and zero otherwise.arrow_forwardWrite a function that takes two integers and returns True if the integers have a common divisor that is different than 1, otherwise returns False. For example, notRelPrime(3,5) returns False, whereas notRelPrime (8,12) returns True. Because, 3 and 5 have only one common divisor, which is 1, whereas 8 and 12 are both divisible by 1, 2 and 4. def notRelPrime (a, b):arrow_forward
- Write the function that takes three dimensions of a brick: height(a), width(b) and depth(c) and returns true if this brick can fit into a hole with the width (w) and height(h). Examples doesBrickFit(1, 1, 1, 1, 1) → true doesBrickFit(1, 2, 1, 1, 1) → true doesBrickFit(1, 2, 2, 1, 1) false Notes • You can turn the brick with any side towards the hole. • We assume that the brick fits if its sizes equal the ones of the hole (i.e. brick size should be less than or equal to the size of the hole, not strictly less). • You can't put a brick in at a non-orthogonal angle.arrow_forwardIn Kotlin, write a higher-order function with an expression body that takes an int n and a function f from int to int and returns the result of calling f(f(n)). For example if you call the function with n = -5 anda function that calculates absolute value, your function will return 5, and if you send the value 2 and a function that calculates the sqaure of an int, the function will return 16. in addition to the function, write the syntax to call it with:a. a function name as the function arguementb. some lambda expression as the function argumentarrow_forwardwrite c++ program Write a function, isPalindrome, that returns true if a string is a palindrome and false otherwise. A string is a palindrome if it reads forward and backward in the same way. For example, the strings "madamimadam", "5", "434", and "789656987" are all palindromes. The prototype of the function is as follows: bool isPalindrome(string str);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
Computer Programming for Beginners | Functions, Parameters & Arguments | Ep24; Author: Programming With Avelx;https://www.youtube.com/watch?v=VXlh-qJpfw0;License: Standard YouTube License, CC-BY