Write a Python function that takes two parameters which are strings, consisting only of digits 0 through 10 as characters. t1 and t2 are not empty. use the int () conversion. If the two integers represented by these two strings are both even or both odd, then the result of the function is the sum of these two integers. Otherwise, the result of the function is the product of these two integers. The function must return (return) this result (which will therefore also be of type integer).
Q: Write a python program that takes an input from a user which is a sequence of any characters. Pass…
A: In this question, we asked to write a python program where function return a modified string after…
Q: Write a Python function called is_palindrome that takes a string as input and returns True if the…
A: Start Read the input. Call the is_palindrome(). Check if palindrome or not. Return true or false.…
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 program in C++, to read a string (M[10]) ,send it to a function (My F()) that finds: 1."NL"…
A: #include <iostream>#include <cctype>#include <cstring>using namespace std; void…
Q: Write a Python function that prints x positive multiples of 4 starting with 4, where x is a argument…
A: Please find the solution below
Q: Write a python program that takes a string parameter called sentence as the input parameter. This…
A: TO solve this i will use simple slicing of array and upper() method of python, I will not use any…
Q: Question: Write a Python program to construct Newton's Divided difference interpolating polynomial…
A: The solution to the given question is: def proterm(i , value, x): pro = 1; for j in range(i): pro =…
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: Illustrating your answer using the buggy code below, explain in your own words what it means for…
A: A variable is said to be local when it's declared within body of method.
Q: Write a Python function that takes an Integer number, N (num of triangles), and string which…
A: def findMaxArea(N,values): #Defining function findMaxArea with N and string parameter values…
Q: Write a Python function greeting that, given a string and a name, returns a friendly greeting…
A: Please check step 2 for the code. Please see that I have used the index function to find the index…
Q: Write a python function Summation(n) that takes a number n as a parameter and print out the integers…
A: The function to print summation can be created as follows: Two loops will be used. The outer loop…
Q: Write a python program with function called area_circumference_generator that takes a radius of a…
A: Prompt to enter the radius of the circle of float type. Accept the value and store it in a variable.…
Q: Write a function that takes in three numbers as parameters and prints out the largest of the three.…
A: Program to write a function that takes in three numbers as parameters and prints out the largest of…
Q: Write a program to read a sequence of integer numbers until it enters a negative number, then prints…
A: I give the code in C++ along with output and code screenshot
Q: Write a function print_sqare() which • takes 2 integers, x and y as parameters • prints the sum of…
A: By accepting x and y values, we have to print x2 , y2 and x2+y2 inside the function
Q: Write a complete C program, WITH ERROR CHECKING, functions and files, that reads a function…
A: Write a complete C program, WITH ERROR CHECKING, functions, and files, that reads a function…
Q: Write a python program that contains a function called reveal_recursive() that takes a word (string)…
A: here we have given code for the mentioned problem
Q: I'm trying to write a function that turns a string with a digit into an integer, the same as int(),…
A: The answer is option first which is ord(g)-ord('0')
Q: Write a function in python that takes three numbers as parameters, and returns the median value of…
A: Python: Python is a very popular language of present time. Python is a scripting language that is…
Q: Write a program that reads a string and outputs the number of times each lowercase vowel appears in…
A: Algorithm: 1. Start 2. Read string 3. Iterate through the string and if the character is an vowel…
Q: I'm trying to write a function that turns a string of digits into an integer, the same as int(, for…
A: I have provided Answer, PYTHON CODE , CODE SCREENSHOT and OUTPUT…
Q: The latest version of Python is 3.7.4. how can we sum up the values of euro sales and asian sales if…
A: Here, I have to write a python solution to the above question.
Q: Write a function that returns the average of the first N numbers, where N is a parameter.
A: The required function is shown below. //function to find and return the average of first N…
Q: Write a python function matching the docstring below. You do not have to include the docstring in…
A: According to the provided information, The python function should convert a time (string) in Eastern…
Q: Write a Python function round_up that, given an integer, rounds it up the next multiple of 100. If…
A: Step 1: start Step 2: accept number as argument Step 3:if number is divisible by 100 then print…
Q: Write a python function that takes a list as a parameter. The list consists of scores of 3 sections…
A: Returning the multiple values from the python function: The function that returns multiple values…
Q: Write a c++ program that takes a date in the following format: December 24th, 2021 and extracts the…
A: The program is written in c++. Here, December 24th, 2021 and extracts the day, month, and year as 3…
Q: Write a function that takes a list of hours and returns the total weekly salary. • The input list…
A: 1. Create the Method with the argument of the list of hours 2. return hours with function switch(i)…
Q: Write the definition of a bool function named BooleanMode () whose header is bool BooleanMode (bool…
A:
Q: Write a python function that takes a string as an argument. Then converts this string using the…
A: We can simply use a list to mention all vowels and check whether character is in that list or not
Q: Write a function to calculate the hypotenuse using Pythagorean theorem: = Vla? + b?) To do this you…
A: Dear learner , hope you are doing well , I will try my best to answer this question. Thank You!!
Q: Encapsulate the following Python code from Section 7.5 in a function named my_sqrt that takes a as a…
A: I'm providing the python code, SS of code for reference, and then the output. I hope this will help.
Q: Write a python function which will take a string as an argument. #First task is to take a string as…
A: Algorithm: Start Read a string Store the count of a,b,c,d,e,f,g,h,i,j if present in the string If…
Q: sumDigits, then, finds the smallest integer between f and t (both inclusive) whose sum of digits is…
A: function sumDigits(f,t,x): Start for f to t follow steps 3 to 8 n=i sum=0 while n>0 follow steps…
Q: Write a function that takes as a parameter an integer (as a long long value) and returns the number…
A: Program code: //include the required header files #include <iostream> using namespace std;…
Q: Write a function check_vowels() that gets a string as a parameter and check if every vowel is…
A: Required:
Q: Implement a function alterCase in Python that converts a word to "alterCase". Given a word, using…
A: Input Data : The string from the user Output Data : Altering the string as per the given…
Q: Define a function in Python that takes a positive integer n as a parameter and prints all numbers in…
A: Hi. Let's move on to the code in the next step. I have included comments in the code that will…
Q: Write a program that reads a sequence of input values and displays a bar chart of the values, using…
A: the program is an given below : def readInts(): '''Read integers until user enters q''' ints…
Q: Write a program in Python with a function biggestBuried(s), which the parameter s is a string, and…
A: - We need to highlight the code for the provided question.
Q: Write a python function called findTriangleArea (a, b, c) that can use Heron's formula to find the…
A: Code: def findAreaTriangle(a,b,c): s = (a + b + c) / 2 area = (s*(s-a)*(s-b)*(s-c)) ** 0.5…
Q: Define a function in Javascript that takes two integers x, y as the parameters and returns the sum…
A: Define a function in Javascript that takes two integers x,y as the parameters and returns the sum of…
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 Python program using functions that WIll ask the user for a humber, then based on tne…
A: program code: '''def main(): #toread input a=input("input number:")…
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,…
Q: ***python only *** Write a function that takes two parameters, a and b, both are strings taken from…
A: used construct:- while construct if else Rule:= paper vs rock-> paper wins Rock vs…
Q: Write a function can_write(letters, word) that returns True if the word of argument word can be…
A: Step 1 : Start Step 2 : Define the function can_write() which accepts 2 strings as parameter. Step 3…
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images
- Write 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”) # TrueWrite 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.Write a program in Python with a function perfectcube(n), which returns True if n is a perfect cube and returns False otherwise. Notice that this function is not printing anything, but rather returning True or False. The function must use exhaustive enumeration to check if n is a perfect cube. Use the function in a program where you ask the user for n and you print a statement like "Yes, that is a perfect cube" or "No, that number is not a perfect cube".
- 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 55***python only *** Write a function that takes two parameters, a and b, both are strings taken from "SCISSORS", "PAPER", or "ROCK, and returns True if a wins over b according to the rules of theScissors-Paper-Rock game; False, otherwise. For example, when a is "SCISSORS" and b is "PAPER", the function should return True.Write a python function that takes a list as a parameter. The list consists of scores of 3 sections of the IELTS exam (reading, writing, and speaking in the exact order). The valid score for each section is from 0(inclusive) to 9(inclusive). Thus the valid range of the IELTS average score is from 0(inclusive) to 9(inclusive). Then your function should return the average of the given scores as well as the information according to the provided conditions below. Then, finally print the returned values in the function call.If the average score is Less than 6, then return “Retake the exam”.If the average score is Greater than 6 and less than 8, then return “Good user”.If the average score is Equal to 8, then return “Very good user”.If the average score is Above 8, then return “Expert user”.For any invalid inputs (out of valid range), return “Impossible score!!”.
- Write a function CountEvens() that has four integer parameters, and returns the count of parameters where the value is an even number (i.e. evenly divisible by 2) in c++Write program in python with a function occupy(n), which shows how birds are going to occupy n nests, assuming that each new bird will choose the nest in the middle of the largest unoccupied run of nests. For example, if there were 10 nests, occupy(10) would print out the following sequence, where underscore indicates an unoccupied nest, and X indicates an occupied nest. The first line of the printout is just 10 underscores showing that all the nests are unoccupied. The second line shows that a bird came to nest in position 5, since that is one the first middle positions of the unoccupied run from 0 to 9. In the third line a bird came to occupy the middle position for the longest open run of nests, from 0 to index 4.Write 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.
- Write a Python function that takes as inputs a vector of values and returns a vector of semivariances, which we will define as the Euclidean distance between each pair of observations: , where x_i and x_j represent different values. Your code should compute and return the semivariance as a vector, with no repetitions (i.e., you can't just use a simple double for-loop because ). There are several possible ways to solve the problem, including a modified double for-loop, or write a separate function. (2,5,6)Write a python function which will take a string as an argument. #First task is to take a string as user input and pass the value to the function. #Second task is to implement a function which will check whether all the alphabets from a to j (convert all the alphabets to lowercase) has appeared at least once in the given string or not. If all of these alphabets (a to j) appear at least once, then the result will be 5. If any one of the alphabets (a to j) is not in the given string, then the result will be 6. Return this result and print the statement, "Chelsea is the best club in England" that many times. Example01: "A black jackal is hunting a full grown deer" Here all the alphabets from A to J are present at least once. So, the function will return 5 and will print the statement 5 times. Input:"A black jackal is hunting a full grown deer"Function Call:function_name("A black jackal is hunting a full grown deer")Output:Chelsea is the best club in EnglandChelsea is the best club in…Write a program in python with a function perfectcube(n), which returns True if n is a perfect cube and returns False otherwise. The function must use exhaustive enumeration to check if n is a perfect cube. Use the function in a program where you ask the user for n and you print a statement like "Yes, that is a perfect cube" or "No, that number is not a perfect cube", as appropriate.