Computer Science: An Overview (12th Edition)
12th Edition
ISBN: 9780133760064
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 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
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")
uestion 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).
Chapter 6 Solutions
Computer Science: An Overview (12th Edition)
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
?.1 Define the different reference meridians that can be used for the direction ofa line.
Elementary Surveying: An Introduction To Geomatics (15th Edition)
How Old Would You Be on Mercury? The length of a Mercurian year is 88 Earth days. Write a program that requests...
Introduction To Programming Using Visual Basic (11th Edition)
The command from the JDK compiles a Java program.
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Comprehension Check 8-14
An 8-liter [L] container holds nitrogen (formula: N2. molecular weight = 28 grams per ...
Thinking Like an Engineer: An Active Learning Approach (4th Edition)
Porter’s competitive forces model: The model is used to provide a general view about the firms, the competitors...
Management Information Systems: Managing The Digital Firm (16th Edition)
The ________ object is assumed to exist and it is not necessary to include it as an object when referring to it...
Web Development and Design Foundations with HTML5 (8th 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
- 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_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_forwardWrite 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_forward
- write 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_forwardWrite a function that replaces a substring with a new string. Example: >>> replace('The quick brown fox jumps over the lazy dog', 'quick', 'slow') The slow brown fox jumps over the lazy dog The first parameter is the string, second is the substring to be replaced and the third is the string to replace the substring. If there are more than one occurrence of a substring, replace it all.arrow_forwardWrite a program that inputs a student's name in the following form: lastName, firstName middleName. The program will convert the name to the following form: firstName middleName lastName. Your program must read the student's entire name in one variable and must consist of a user-defined function that takes as input a string, consisting of a student's name, and returns the string consisting of the altered name. You can use the string function find to find the index of ,(the comma); the function length to find the length of the string; and the function substr to extract the firstName, middleName, and lastName.arrow_forward
- Write out a function that prints out all the permutations of a string. For example, abc would give you abc, acb, bac, bca, cab, cba.arrow_forwardA natural number is prime if it is greater than 1 and has no divisors other than 1 and itself. Example: 8 isn't a prime number, as you can divide it by 2 and 4 (we can't use divisors equal to 1 and 8 as the definition prohibits this). On the other hand, 7 is a prime number as we can't find any legal divisors for it. Your task is to write a function checking whether a number is prime or not. in phython langauge Ques: The function: is called IsPrime() takes one argument (the value to check) returns True if the argument is a prime number, and False otherwise. Hint: try to divide the argument by all subsequent values (starting from 2) and check the remainder - if it's zero, your number cannot be a prime; think carefully about when you should stop the process. If you need to know the square root of any value you can utilize the ** operator. Remember: the square root of x is the same as x**0.5 Write a code that calculates all the prime numbers between 1 and 20. (Hint: Use a loop and…arrow_forwardA natural number is prime if it is greater than 1 and has no divisors other than 1 and itself.Example: 8 isn't a prime number, as you can divide it by 2 and 4 (we can't use divisors equal to 1 and 8 as the definition prohibits this). On the other hand, 7 is a prime number as we can't find any legal divisors for it.Your task is to write a function checking whether a number is prime or not.The function:•is called IsPrime()•takes one argument (the value to check)•returns True if the argument is a prime number, and False otherwise.Hint: try to divide the argument by all subsequent values (starting from 2) and check the remainder - if it's zero, your number cannot be a prime; think carefully about when you should stop the process.If you need to know the square root of any value you can utilize the ** operator. Remember: the square root of x is the same as x**0.5Python programming question Write a code that calculates all the prime numbers between 1 and 20. (Hint: Use a loop and call the…arrow_forward
- A natural number is prime if it is greater than 1 and has no divisors other than 1 and itself. Example: 8 isn't a prime number, as you can divide it by 2 and 4 (we can't use divisors equal to 1 and 8 as the definition prohibits this). On the other hand, 7 is a prime number as we can't find any legal divisors for it. Your task is to write a function checking whether a number is prime or not. Please us phython language The function: is called IsPrime() takes one argument (the value to check) returns True if the argument is a prime number, and False otherwise. Hint: try to divide the argument by all subsequent values (starting from 2) and check the remainder - if it's zero, your number cannot be a prime; think carefully about when you should stop the process. If you need to know the square root of any value you can utilize the ** operator. Remember: the square root of x is the same as x**0.5 Write a code that calculates all the prime numbers between 1 and 20. (Hint: Use a loop and…arrow_forwardHow to write a function in python that takes a string s = kkeeepinng and returns the non-repeating character from strrint s. Such that the output should be as follows: p i garrow_forwardGiven a letter, created a function which returns the nearest vowel to the letter. If two vowels are equidistant to the given letter, return the earlier vowel. Examples nearest Vowel("b") - "a" nearestVowel("s") → "u" nearest Vowel ("c") → "a" nearest Vowel("i") → "i"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