Question 3: ----- Write a function replace_head_tail that takes a string strl and replaces the first X and last Y characters of the string and returns the resulting string. For example, replace_head_tail("corona virus", 4, 3) returns "rusna vicoro". You can assume that the string will always contain at least X+Y characters. def replace_head_tail (stri, X, Y) : # Remove this line before you answer this question. If you will NOT answer # this question, then do NOT remove this line. return
Q: Question 2: Write a function called number_matrix(r,c) that takes two parameters r and c and PRINTS…
A: In given problem it has been asked to write a function number_matrix(r,c) that takes two parameter r…
Q: 1- Write a function that takes a word less than 25 characters long and returns the letter that word…
A: NOTE:- AS PER OUR POLICY WE CAN SOLVE ONLY ONE QUESTION AT A TIME. SO, PLEASE REPOST THE REST…
Q: 2. Write a function RightFill(s, n) which fills the string s with blanks from the right until its…
A: MATLAB means MATrics LABoratory , as the name suggests it is actually used for matrix. Though it is…
Q: Define the is_a_valid_code() function which is passed a string code as a parameter. The function…
A: Given:- use py only
Q: Question 5: Write a function that takes a string representing the binary representation of a number,…
A: Objective: This program includes a user-defined function to determine the decimal number from the…
Q: Write a function that accepts two strings of equal length and returns a strings where the characters…
A: Aim: To write a function that accepts two strings of equal length and returns a string where the…
Q: 1- Write a function that takes a word less than 25 characters long and returns the letter that word…
A: #include <stdio.h> #include <string.h> #include <ctype.h> // returns the first…
Q: 3. Write and test a function hydroxide that returns a 1 for true if its string argument ends in the…
A: As per our guidelines we are supposed to answer only one question. Kindly repost the remaining…
Q: Ask the user to enter the following statement: "I like programming in C++ because C++ is fun and…
A: #include <bits/stdc++.h> using namespace std; #define int long long int int Count(string s…
Q: write pyhton code with indentation and alternative solution for; Write a function called…
A: def reverse_only_letters(argument): string = [] #convert the given string to list as it is…
Q: rps (Exercise 5.26 from the textbook) Write a function rps that returns the result of a game of…
A: The solution for the above given question is given below:
Q: 8. Write a function biggestBuried(s), which the parameter s is a string, and the function returns…
A: A Regular Expressions (RegEx) is a special sequence of characters that uses a search pattern to find…
Q: Using the function from the previous problem, write a function durdle_game(target) which takes in as…
A: Please find the answer below :
Q: Write a function called convert_case( string, upper=False ) that takes a string and returns a new…
A: As per the Bartleby guideline, the first question only get solved, If you have multiple questions in…
Q: 3. Write and test a function hydroxide that returns a 1 for true if its string argument ends in the…
A: The complete code is given below.
Q: Write a function that receives a string of characters as its input, and check if it is symmetric to…
A: Actually, string is a sequence of characters.
Q: 8. Write a function called string_reverse() that accepts a string from the user as a parameter. The…
A:
Q: Write a function to replace all instances of character c1 with character c2 and vice versa. Examples…
A: function doubleSwap(str, c1, c2) { let newstr = ''; for (let i = 0; i < str.length; i++){ if…
Q: Suppose that you have the following function definition. int find(int x, int y){return (x + y - x *…
A: (a) The function call u = find (list1[0], v); is valid. Explanation: An integer arrays list1[0] and…
Q: Write a isPalindrome Function Write a function isPalindrome($str) that returns true if the parameter…
A:
Q: Solution in JS Write a function that inserts a white space between every instance of a lower…
A: logic - return s.replace(/([a-z])([A-Z])/g, "$1 $2"); Input - String Output - String with white…
Q: Write a function that counts and returns the number of vowels in the string. (For the purposes of…
A: The main objective of the c++ program, main. cpp is to prompt the user to enter the menu choice. The…
Q: 2) Write a general program that takes an integer value from the user. Then generates a Prime…
A: #include<iostream> #include <cmath> using namespace std; // function to calculate and…
Q: Write a function called "reverse" that accepts a dictionary as a parameter and returns a dictionary…
A: def reverse(Dict): print("Input dictionary : ") print(Dict) rDict={} for key, value in…
Q: (1.13) A binary number is passed as a parameter to a function in the form of a binary string. Write…
A: Since the programming language is not mentioned so I have used the C++ programming language.…
Q: Create a function that takes a string with at least one sentence in it and returns a string with the…
A: function reverseLegoYoda(text) { let arr; let tex = ""; let array = text.split(". "); for (let i =…
Q: Create a function reduce, which takes a string as its argument and prints the reduced characters of…
A: Question:
Q: C++ Coding Question, Fill the void function *n1, int *n2, int *n3) void passReference(int ( // Write…
A: Coded using C++.
Q: C++ Coding Question, Fill the void function *n1, int *n2, int *n3) void passReference(int ( // Write…
A: Coded using C++.
Q: Solution in JS Write a function that inserts a white space between every instance of a lower…
A: The Javascript code is given below with code and output screenshot Happy Coding?
Q: Write a function with the following header to format a positive integer with the specified width:…
A: Program approach:- Import a package to get the standard I/O. Define a class. Define the main…
Q: Create a function that takes two integers, num and n, and returns an integer which is divisible by n…
A: As no programming language is mentioned, it is solved using basic Python
Q: Write a function called average that takes AS MANY ARGUMENTS as the caller wants to give, and…
A: Note: Since no programming language is mentioned, the program has been implemented in Java. Java…
Q: Write a function longestRun($str) that takes a string as a parameter and returns the length of the…
A: The answer is
Q: 3. Write and test a function getDigits(s) that returns a string of all digits found in s (in the…
A: In this question we have to code and implement to python function which will extract the digits…
Q: Write a user-defined function that compares two string with each other. If first one is equal to…
A: Function definition: A function is a subroutine that executes a set of instructions or a set of…
Q: please code in python: def best(len_score,lst): max1=0 for i in reversed(lst): temp…
A: In this question we have to write a python code in which, 1) Find the total numbers of vowel a list…
Q: 1- Write a function that takes a word less than 25 characters long and returns the letter that word…
A: To find the capital letter of a word, we can test it against the ASCII values. We know that the…
Q: Solution in JS Write a function that inserts a white space between every instance of a lower…
A: In JavaScript string.replace method/function is used to inserts a white space between every instance…
Q: Complete the below function which takes an integer k and a string s as its arguments and returns a…
A: The program takes two inputs from the user such as integer value of k and string s. k is the int…
Q: Write a function that determines if two strings are anagrams. The function should not be case…
A: Here we will do the above program i.e. check anagrams using C++, kindly check the code.
Q: Given what is supposed to be typed and what is actually typed, write a function that return the…
A: Since the programming language is not mentioned, I have done the code using JavaScript.
Q: Problem 3: Write a function that takes in a string as input and returns a list of the unique…
A: inputString=input().lower(); #accept input string from user and convert to lower case…
Q: 3. Write and test a function getDigits(s) that returns a string of all digits found ins (in the same…
A: The complete Python code is given below with screenshots
Q: please code in python Write a function that receives a string as an input and returns the most…
A: When it is required to find the most frequent character in a string, an empty dictionary is created,…
Step by step
Solved in 4 steps with 2 images
- Write a function replace_head_tail that takes a string str1 and replaces the first X and last Y characters of the string and returns the resulting string. For example, replace_head_tail("corona virus", 4, 3) returns "rusna vicoro".Question 3: Write a function that computes the ratio of vowels vs. consonants (????????????????����������������) in a given sentence. The ratio should be given as a floating-point number rounded off to two decimal places. When writing your function, be sure to appropriately cater for the following punctuation marks: apostrophes (') quotations (") full stops (.) commas (,) exclamations (!) question marks (?) colons (:) semicolons (;) Arguments: sentence (string) →→ sentence required to compute the ratio. Return: ratio (float) →→ a ratio that describes the number of vowels to consonants: vowels/consonants. ?HINT? Remember to cater for the white spaces that appear in your sentence. Expected outputs vowel_consonant_ratio("This is a random sentence!")==0.62 vowel_consonant_ratio("Thomas! Where have you been?")==0.837. Write a function password_check() that takes as input two stringsnewpassword and oldpassword, and that accepts the new password (i.e., returnsTrue) if newpassword is different from oldpassword and newpassword is atleast 6 letters long. If the new password fails the check, your functions should returnFalse.>>> password_check('E10-s2ff', 'E10.s2ff')True>>> password_check('E10sf', 'E10.s2ff')False>>> password_check('E10-s2ff', 'E10-s2ff')False(Extra Credit) For extra credit, extend your password function so that it also checks thatthe new password contains a digit.>>> password_check('E10-s2ff', 'E10.s2ff') True>>> password_check('Eej-sdff', 'E10.s2ff')False
- Create a function that accepts a string (of a person's first and last name) and returns a string with the first and last name swapped. Examples NameShuffle("Donald Trump") - "Trump Donald" NameShuffle ("Rosie O'Donnell") - "O'Donnell Rosie" NameShuffle ("Seymour Butts") - "Butts Seymour" • There will be exactly one space between the first and last name. In c#Please fill the blanks for C. /*getchar VS scanf*/ #include<stdio.h> #define length 70 //Putting all function headers to top __1__ print_scanf(); __2__ print_getchar(); int main() { //print 2 sentences using getchar() for(int i = 0; i < 2; i++) { print_getchar(); } //print 2 sentences using scanf() for(int i = 0; i < 2; i++) { print_scanf(); } return 0; } //Function to print using getchar void print_getchar() { __3__ str[__4__]; //create a string called str with length defined above printf("Enter your sentence for getchar:"); int i = 0; while(1) //run forever,unless there's a break or return { /*save user's input to curChar since we need to check 2 cases: Case 1. if the inputted character is a letter we save curChar to our string (array of char) Case 2. if it's a new line character.…1. Write a function that converts a phrase into pig Latin. A word is convertedto pig Latin by removing the first character of the word, placing it at theback of the word, and adding the characters “ay” to the word. For example,“hello world” in pig Latin is “ellohay orldway.” Your function can assumethat each word consists of at least two letters and that each word is separatedby one space, with no punctuation marks.2. Write a function that counts the occurrences of a word in a string. Thefunction should return an integer. Do not assume that just one space separates words and a string can contain punctuation. Write the function sothat it works with either a String argument or a StringBuilder object.3. Write a function that takes a number, such as 52, and returns the numberas a word, as in fifty-two.4. Write a subroutine that takes a simple sentence in noun-verb-object formand parses the sentence into its different parts. For example, the sentence“Mary walked the dog” is parsed into…
- 14. In written text small numbers are often written out, e.g. you'd write 'I have twobrothers and one sister', rather than 'I have 2 brothers and 1 sister'. Here we want toimplement one (1?) function that helps us realize this. Write a function smallnr() thattakes a number x and if x is an integer between 0 and 6 it returns the name of thenumber, otherwise it simply returns x as a string.>>> smallnr(2)'two'>>> smallnr(0)'zero'>>> smallnr(7)'7'3. Write a function that uses regular expressions to extract SIN numbers with either dashes or spaces between the numbers, but not any other characters. E.g. the string 'My SINs are 123-456-798 and 987 654 321, and 987/432/321' should return the list ['123-456-798', '987 654 321']Create a function sumofAllOdd(s,e) that will return the sum of all odd numbers in a range of inputted numbers s (starting number), e(ending number). For example: Test Result sumofAllOdd(22,55) sumofAllOdd(5,10) Answer:(penalty regime: 10, 20, ... %)
- How could a create a function that drops the lowest grade on this grading calculator? For example: John 100 100 0 = D Create a function to drop the lowest grade so John 100 100 (0 dropped) = A #include<iostream>#include<string>using namespace std; char getGrade(double average){ if(average>=90)return 'A'; else if(average>=80)return 'B'; else if(average>=70)return 'C'; else if(average>=60)return 'D'; else return 'F';} void sort(string lastnames[] , char grades[], int n){ for(int i=0;i<n;i++){ for(int j=0; j<n-i-1;j++){ if(lastnames[j].compare(lastnames[j+1])>0){ string temp = lastnames[j];lastnames[j]=lastnames[j+1];lastnames[j+1]=temp; char t = grades[j];grades[j]=grades[j+1];grades[j+1]=t; } } }} int main(){ int students; int s1,s2,s3; double average; cout<<"This is an automatic grade calculator. Please enter the number of students in the class:\n"; cin…Write a function str_replace that takes three strings, str1, str2 and str3; and replaces the first occurence (if any) of str2 in str1 with str3, and returns the newly formed string. For example, str_replace("Nuclear Energy Engineering", "Nuclear Energy", "Mechanical") returns "Mechanical Engineering"3. Find Relatively Prime Write a function to return a number that is relatively prime with the given number. /* return an integer that is relatively prime with n, and greater than 1i.e., the gcd of the returned int and n is 1 Note: Although gcd(n,n-1)=1, we don't want to return n-1*/int RelativelyPrime (int n) 4. Find Inverse Then implement the following function, which returns the inverse modulo, and test it.Note that you need to check whether a and n are relative prime before calling thisfunction. Recall that a and n are relatively prime means that gcd(a,n)=1, i.e., theirgreatest common divisor is 1. Also recall that the extended Euclidean Algorithm canfind the integer s and t for a and n such that as+nt=gcd(a,n), where s is the inverseof a modulo n. /* n>1, a is nonnegative *//* a<=n *//* a and n are relative prime to each other *//* return s such that a*s mod n is 1 */int inverse (int a, int n){int s, t;int d = ExtednedEuclidAlgGCD (n, a, s, t);if (d==1){return (mod (t,…