
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Write a program called p3.py. Write a function called validate() that takes a string as input, validates that it is a single letter, and returns the letter in lowercase.
Example:
validate(“A”) returns a
validate(“abc”) returns invalid
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 2 images

Knowledge Booster
Similar questions
- Write a C++ program that reads a sentence into a c-string of maximum 80 characters, a character into a variable called c, and an integer into n, and then passes all three of these variables to a function that searches for the character c and prints the character and the next n characters of the string, if the character is found. If it doesn't find the character in the string it must print "The character was not found." For example, if the user enters "Superbowl tickets are too expensive." and then enters t and 7, the function must print tickets.arrow_forwardCreate a function that will test if a string is a valid PIN or not via a regular expression. A valid PIN has: Exactly 4 or 6 characters. Only numeric characters (0-9). • No whitespace. Examples validate("121317") → true validate("1234") → true validate("45135") → false validate("89abc1") → false validate("900876") → true validate(" 4983") falsearrow_forwardComplete the rotate_text() function that takes 2 parameters, a string data and an integer n. If n is positive, then the function will shift all the characters in data forward by n positions, with characters at the end of the string being moved to the start of the string. If n is 0 then the text remains the same. For example: rotate_text('abcde', rotate_text('abcde', rotate_text('abcde', 1) would return the string 'eabcd' 3) would return the string 'cdeab' 5) would return the string 'abcde' rotate_text('abcde', 6) would return the string 'eabcd' ... and so on. If n is negative, then the function will shift the characters in data backward by n positions, with characters at the start of the string being moved to the end of the string. For example: rotate text('abcde', -1) would return the string 'bcdea'arrow_forward
- Write a program that removes all spaces from the given input. Ex: If the input is: Hello my name is John. the output is: HellomynameisJohn. Your program must define and call the following function. The function should return a string representing the input string without spaces.string RemoveSpaces(string userString) #include <iostream>#include <algorithm>using namespace std; string removeSpaces(string str) { str.erase(remove(str.begin(), str.end(), ' '), str.end()); return str; } /* Define your function here */ int main() {string str; str = removeSpaces(str); cout << str << endl; /* Type your code here. Your code must call the function. */ return 0;} Please help me with this problem using c++.arrow_forwardUsing Python write a string-comparison function named strNcompare that compares up to n characters of a string s1 with the other string s2. The function must return 0, -1, or 1 if the first n-character portion of s1 is equal to, less than, or greater than the corresponding first n-character portion of s2, respectively. (1) You must use the following function definition: def strNcompare(s1, s2, n): (2) String comparison must be case-insensitive. For example, the strNcompare function must return 0 for the s1 value of ‘tommy’ and the s2 value of ‘TOMMY’. (3) You should not use a loop such as the while loop and the for loop inside the strNcompare function. Then write a Python program that receives two words and the number of characters for comparison, calls the strNcompare function, and then shows the result. Your program keeps doing this until the user enters the value of -1. Your program displays the message ‘String comparison [1(play), -1(quit)]: ’ and receives the value 1 or -1…arrow_forwardWrite a program to enter two strings from the user using function cin.getline and then appends string two with string one separated by a blank space. Sample Input: C++ is a good programming Language. Arrays are very integral part of this language. Sample Output: C++ is a good programming Language. Arrays are very integral part of this language.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education