Write a function encoding that takes a string and an integer as the parameters, and returns a new string, so that at each position, the two characters in the string and the new string are the integer number of positions away from each other in the ASCII character encoding table. Then swap the two half-strings. For example, encoding('ABCabc..10) should return the new string "WXY789". Please write this in Python3 language.
Q: Write a Python function which reads a string and prints the string backwards. Example Input : str =…
A: Task : Write a python program to print the expected output in given question. Python code :-…
Q: Write a function that takes a two-digit number and determines if it's the largest of two possible…
A: Here is the explanation and code for the problem:
Q: Write a C function strsShuffle() that takes three strings (say s1, s2, s3) as parameters, stores…
A: Actually, string is a sequence of characters.
Q: Write a program in JAVA and make a function correct(String s) which removes all the uppercase…
A: Write a program that removes all the uppercase letters in the string correct(String s)
Q: Another question, I suppose to draw a snowflake using this function, but everytime I get to the…
A: Given: Another question, I suppose to draw a snowflake using this function, but everytime I get to…
Q: Write an ASM program that prompts the user to enter a string of at most 128 characters and then…
A: #include<stdio.h>#include<string.h>int main(){ int l,i,Ucount=0,temp; char…
Q: Programed in VBA Excel Program a function that counts the number of vowels in a given text string.…
A: Answer: I have done code and also I have attached code and code output as well as output
Q: Take a string input from the user and print a modified string where the characters in the multiple…
A: Q: Take string input and perform given operations
Q: Write a python program that will take two inputs from the user. One string with a length greater…
A: The concept in the program is that if the index of the string is divisible by the number then we…
Q: Write a python program that can tell if two strings are anagrams with each other. Anagrams are…
A: '''Define the function hat returns True when s1 and s2 are anagrams and returns False otherwise'''…
Q: Write a Python program that uses a function to find and return the factorial of a positive integer…
A: def fact(n): # declaring a function if(n==0): # special case if n is 0…
Q: Implement a function that finds the first position of any characters from a set in a given string.…
A: File name: "strings.cpp" #include <iostream> using namespace std; /*Define a method to find…
Q: Write a C++ program that accepts a positive integer (or string) as input and then displays a new…
A: To replace characters duplicated twice with one character in string
Q: Write a Python function that takes as inputs a vector of values and returns a vector of…
A: Question 1. Write a Python function that takes as inputs a vector of values and returns a vector of…
Q: Write a function separate(String s) in JAVA in which we are given a string s in argument print the…
A: We have to write one program to solve the problem given in the question in the JAVA language. This…
Q: Write a Java program to find out the greatest common divisor of two input values using a function.
A: Algorithm: Read the integer intialise the integer create a function of gcd use if else for…
Q: In Python write a function decoding() that takes an encoded string and an integer as the parameters,…
A: Required: In Python write a function decoding() that takes an encoded string and an integer as the…
Q: Write a function in Python3 to take a string as a parameter and returns the sum of ASCII values of…
A: I give the code in Python along with code and output screenshots.
Q: Write a code in C++: Write a program to factor a polynomial of the form x² + bx + c, where b and c…
A: #include <iostream> //Including iostream header file#include <cmath> // Including…
Q: Write a C program that reads the exam data for each student in a line to be entered from the…
A: According to the Question below the Program: Program Output:
Q: Write a Python function that checks a string and returns True if it is palindrome and False if it is…
A: #return if s is palindrome or not def isPalindrome(s): if s==s[::-1]: return True…
Q: Write a C function strsShuffle() that takes three strings (say s1, s2, s3) as parameters, stores…
A: The str_shuffle() - Randomly shuffle all characters of a sting. Here below is the code :…
Q: Write a function countTypes(s1) that gets one string. Count and print all lower case, upper case,…
A: Given a string, write a program to count the occurrence of Lowercase characters, Uppercase…
Q: Write a c program that uses six calls to the function rand () to generate six random integer…
A: #include <stdio.h>#include <stdlib.h>#include <time.h>int main(){ int num1,…
Q: we will pretend that bits are sent as strings (they are not; this would be terribly inefficient).…
A: Odd Parity is 001110110, the equality bit is zero with the goal that the all out number of 1's in…
Q: Write a C program that reads the exam data for each student in a line to be entered from the…
A: Given: Write a C program that reads the exam data for each student in a line to be entered from the…
Q: Write the function printJAVA that takes an integer n3 (n is equal or greater than 0) and returns a…
A: Logic : Use one additional loop to check if current value from 0 to n3 lies in range of power of 2…
Q: decimal and returns this value. The string consists of "." and "-" characters, where "." represents…
A: Please find the answer below :
Q: Write a python function that gets the list of course ID's a student takes until his graduate, and…
A: for item in a: if(item[:2]=="MF"): mylist.append(item)
Q: Write a function biggestBuried(s), which the parameter s is a string, and the function returns the…
A: 1) Below is program that define function biggestBuried(s), in which the parameter s is a string, and…
Q: Take a string input from the user and print a modified string where the characters in the multiple…
A: ## As no programming language is mentioned, the code is written in Python. str1 =…
Q: Write a C++ program that would implement the function called romanToInt which returns the integer…
A: - We have to code for the conversion problem.
Q: Write a function separate(String s) in JAVA in which we are given a string s in argument print the…
A: Algorithm: Start Read a string s Implement a method separate(), which takes a string as argument…
Q: Write a C function strsShuffle() that takes three strings (say s1, s2, s3) as parameters, stores…
A: Given: Write a C function strsShuffle() that takes three strings (say s1, s2, s3) as parameters,…
Q: Write a function add(String a, String b) which prints the concatination of string a and b in JAVA…
A: We need to write a function in JAVA where we have to print the contamination of the two strings…
Q: Write a function hideShow that accepts two string arguments, an input string and a masking string.…
A: Answer is given below .
Q: Write a Python Program to Count Occurrences of a certain Character in a String. The user inputs a…
A: #python program to read a string and a char#the finds and prints the no of occurences of char in…
Q: Write a program in JAVA and make a function void replace(String s) which replaces all the uppercase…
A: We have to write a function replace(String s) to replace all the uppercase letters with special…
Q: Write a program in C++ language that reads three integers from the keyboard, then there is a cube…
A: #include<iostream> using namespace std; int main(){ int a,b,c,cube_a,cube_b,cube_c;…
Q: Let f be a function that takes some natural number n, and adds the value that n takes when its…
A: This program is to return a list of numbers with reversed operations and summing up them up for next…
Q: Write a Python function decode(s) that decode a string in a specific way. We assume the first…
A: The following python code is given in the answer attached below. A Test case is also performed and…
Q: Write a program to determine the possible location(s) of a missing symbol of enclosure given a…
A: SOLUTION: For full understanding explanation (how to approach ) , c++ code and along with screenshot…
Q: Write a python function that takes a string as a parameter. Then your function will check the…
A: We use ord() method to get ASCII value of the character and chr() method is used to get the…
Q: Write a program in C programming language that takes two arguments at the command line, both…
A: #include<stdio.h> int main() { char string[80], searchString[10]; int count1 = 0,…
Q: Write a python function count_matches that, given two strings, counts the number of positions at…
A: Define the method with two string arguments. Initialise a integer variable "count" with 0. Check if…
Q: Write a python program that takes a string as an input from the user and then modifies the string in…
A: In the given code below The user must provide the input_string value. The if-else loop is used to…
Write a function encoding that takes a string and an integer as the parameters, and returns a new string, so that at each position, the two characters in the string and the new string are the integer number of positions away from each other in the ASCII character encoding table. Then swap the two half-strings. For example, encoding('ABCabc..10) should return the new string "WXY789". Please write this in Python3 language.
Step by step
Solved in 3 steps with 2 images
- Write a program that inputs a line of text and a search string from the keyboard. Using function strstr, locate the first occurrence of the search string in the line of text, and assign the location to variable searchPtr of type char *. If the search string is found, print the remainder of the line of text beginning with the search string. Then, use strstr again to locate the next occurrence of the search string in the line of text. If a second occurrence is found, print the remainder of the line of text beginning with the second occurrence. input Input a line of text and a search string. Maximum number of char is 200. Output Print the remainder of the line of text beginning with the search string.Write a Python function that takes a sequence of characters and determines if there are any pairs of characters that are not adjacent to each other by returning True if there are any pairs, or False Example: The string “abbot” would return False because the two b’s are adjacent to each other while the string “abba” would return True because, even though the two b’s are adjacent to each other, the two a’s are not.In Python write a function decoding() that takes an encoded string and an integer as the parameters, and returns the original string. The encoding was performed as follows. First, the original string is reversed. Then, each character in the new string is replaced by the character that is a given number of positions away in the ASCII character encoding table. For example, the following call to yur function : encoding('ABCabc', -10) should return the encoded string 'YXW987'.
- Write a python function that takes a string as a parameter. Then your function will check the ascii value of each character present in the string and form a new string containing only the EVEN valued characters. Then, return the newly formed string and finally print the returned value in the function call.Here, an even valued character is a character whose ascii value%length of the string is even.================================================Sample Input 1:holaSample Function Call 1:function_name("hola")Sample Output 1:hlExplanation 1:Length of "hola" is 4.ASCII of ‘h’ is 104. So, 104%4=0 which is even. So, add it to the new string.ASCII of ‘o’ is 111. So, 111%4=3 which is odd. So, do not add it to the new string.ASCII of ‘l’ is 108. So, 108%4=0 which is even .So, add it to the new string.ASCII of ‘a’ is 97. So, 97%4=1 which is odd. So, do not add it to the new string.================================================Sample Input 2:"bye"Sample Function Call…Write a program in python with a function repeatPhrase(phrase, n), which prints the given phrase n times, alternating between lowercase and uppercase. For example, repeat('The sky is yellow', 5) would print: the sky is yellowTHE SKY IS YELLOW the sky is yellowTHE SKY IS YELLOW the sky is yellowWrite a Python function called is_palindrome that takes a string as input and returns True if the supplied string is a palindrome or False if not. For our purposes, a palindrome is any string that: ● reads the same backwards and forwards, ignoring letter case and spaces*, and ● is at least 2 characters** in length. *For example, “Radar” is a palindrome even though the first letter is uppercase but the last letter is lowercase. The phrase “taco cat” should also be considered a palindrome because it reads the same backwards and forwards when the space is ignored. **This includes non-letters, such as punctuation and numbers. For example, “!radar!” would be considered a palindrome. Example function output: is_palindrome(“madam Im adam”) # True is_palindrome(“a”) # False is_palindrome(“RADar”) # True
- Write a program in Python with a function decimalToBinary(n) that converts a positive decimal integer n to a string representing the corresponding binary number. Do the conversion by repeatedly dividing the number n by 2 using integer division, keeping track of the remainders, until the number is reduced to 0. The remainders written in reverse order form the binary number string.Write a program in Python with a function biggestBuried(s), which the parameter s is a string, and the function returns the largest integer buried in the string. If there is no integer inside the string, then return 0. For example, biggestBuried('abcd51kkk3kk19ghi') would return 51, and biggestBuried('kkk32abce@@-33bb14zzz') would return 33, since the '-' character is treated like any other non digit. print(biggestBuried('abcd51kkk3kk19ghi')) answer should be 51 print(biggestBuried('kkk32abce@@-33bb14zzz')) answer should be 33 print(biggestBuried('this15isast22ring-55')) answer should be 55Write a function that takes a string representing the binary representation of a number, computes the number in decimal and returns this value. The string consists of "." and "-" characters, where "." represents 1 and "-" represents 0. For example, ".--.." corresponds to 10011, which is equal to 1 * 16 + 0 * 8 + 0 * 4 + 1 * 2 + 1 * 1 = 19. So the function returns 19 for an input of ".--..". """
- Write a code in C++: Write a program to factor a polynomial of the form x² + bx + c, where b and c are integers AND also modify the program so that it can also factor polynomials of the form ax2 + bx + c , where a, b, and c are integers. For example, the polynomial "- 2x² - 3x + 2" can be factored as: "- 2x² - 3x + 2 = (-2x + 1)(x + 2) = - (2x - 1)(x + 2)". The output at the end should be this exact quote: "- 2x² - 3x + 2 = (-2x + 1)(x + 2) = - (2x - 1)(x + 2)"Write a function that keeps computing the sum of the digits of x^n, until there is only one digit left. For example, sumOfDigits(2,5) returns 5, because 2 ^ 5 = 32 = 3 + 2 = 5 Another example, sumOfDigits(2,8) returns 4, because 2 ^ 8 = 128 = 1 + 2 + 8 = 13 = 1 + 3 = 4Write a c program to ask the user for a string code, if the user enters the correct code which is “peace”, then allow the user to enter a string that must be less than 35 characters long. If the user enters a wrong code, keep asking until the user enters the correct code. After the user enters the string, find the length of the string, then pass the string (array) to a function that will count the number of character ‘a’ or ‘A’ and returns the count. The calling function gets the number of counts and displays the string plus the count.