Create a python add the following functions below to the module. Each section below is a function that you must implement, make sure the function's names and parameters match the documentation (Copy-Paste). DO NOT put the functions in an if-name-main block.
1.
def productSum(x: int, y: int, z: int) -> int
This function should return:
The product of x and y, if the product of x and y is less than z.
Else it should return the sum of x and y, if the product of x and y is greater than or equal to z.
Example 1:
x = 5
y = 2
z = 9
output = 7 = 5 + 2 because 5 * 2 > 9
Example 2:
x = 4
y = 3
z = 19
output = 12 = 4 * 3 because 4 * 3 < 19
2.
def functionSolver(function: callable)->str
You will be given a function, the function given only accepts two int parameters and produces a float value. It is your job to figure out what mathematical operation the function is performing with the parameters you give it. The possibilities are: add, subtract, multiply, and divide. The function will execute the operation in the order the parameters are received. You must input your own values and test the expected responses to figure out the operation of the function. Once you have figured it out return the symbol of the operation (+, -, *, /)
3.
def resultSolver(x: int, y: int, op: str, override: callable)->int
This function will expect 2 values, x, and y, which will be integers. It will also have two optional values op and override. this function is expected to return an integer. Op will be a string representing a mathematical operation ('+', '-', '*', '/') to be performed between x and y. If op is not defined it should default to addition. Override is a function that accepts two integers and returns an integer as a value. If override is not defined it this function should return the result of x and y computed with the op value. If override is specified this function should return the result of the invocation of override with x and y passed into it.
4.
def nestedRemoval(text: str, leftPattern: str, rightPattern: str) -> str
You will be given three strings, the first string is a sentence known as text that contains at least one occurrence of leftPattern and rightPattern. Left pattern and right pattern are single characters strings that you are attempting to remove from the string. Your goal is to remove only the patterns when the left pattern has an equal number of corresponding right patterns. The patterns are removed in pairs only when there is a balanced number of left and right patterns. The patterns may be nested within the text and there is no guarantee that a left pattern will occur before the right pattern.
Example 1:
text = { { Muscat } } { } mecum tollgate } poultry quarrymen pantheon asteria
leftPattern = {
rightPattern = }
return = Muscat mecum tollgate } poultry quarrymen pantheon asteria
Example 2:
text = theretofore [ ] [ ] demography ] ] pirouetting morsel [ [ pesticide
leftPattern = [
rightPattern = ]
return =. demography ] ] pirouetting morsel [ [ pesticide
Example 3:
text = ( castigate ) alfonso ( ) ) ) emitter sourdough ) taco ( schemata
leftPattern = (
rightPattern = )
return = castigate alfonso ) ) emitter sourdough ) Lauren ( schemata
MULTIPLE QUESTION. Specific question not specified.
Answer to the question number 1.
It uses Python if and else statements;
General syntax for if and else statement in python
is
if <condition> : <Statement 1> else : <Statement 2>
so for the function def productSum(x: int, y: int, z: int) , the code is as follows,
def productSum(x: int, y: int, z: int) -> int: if x*y<z: return x*y else: return x+y
Please note that the syntax for a function is as follows,
def <Function name> : < statements ...... > return <value/variable>
Create a python add the following functions below to the module. Each section below is a...
python: def functionSolver(function: callable)->str You will be given a function as a parameter, the function you are given only accepts two number parameters and produces a float value. It is your job to figure out what mathematical operation the function you are given is performing by passing it many different parameters. The possible operations the function can perform are: add, subtract, multiply, and divide. The given function will only perform a single operation, it will not change after consecutive invocations....
Hello, In Python Enhance the prior assignment by doing the following 1) Create a class that contain all prior functions MyLib # This function adds two numbers def addition(a, b): return a + b # This function subtracts two numbers def subtraction(a, b): return a - b # This function multiplies two numbers def multiplication(a, b): return a * b # This function divides two numbers # The ZeroDivisionError exception is raised when division or modulo by zero takes place...
In PYTHON!
Exercise 3: Lists and Functions In this exercise we will explore the use of lists and functions with multiple inputs and multiple outputs. Your task is to implement the separate_and_sort function. This function takes two input parameters: 1. A list containing strings and integers in any order. 2. An optional integer parameter size which controls how many items in the list the function will process. If the length of the list is smaller than the value of size,...
In Python, starting with the 8x8 board solution that will be appended here add the following functionality: 1) Add code to create a list, containing 8 lists, with each of the 8 lists containing 8 null strings as values. Call the list of lists board. code provided by prof: import turtle validMovesList=['A0','A2','A4','A6','B1','B3','B5','B7', 'C0','C2','C4','C6','D1','D3','D5','D7', 'E0','E2','E4','E6','F1','F3','F5','F7', 'G0','G2','G4','G6','H1','H3','H5','H7','quit'] def drawSquare(t,length,color): t.fillcolor(color) t.begin_fill() for num in range(4): t.forward(length) t.left(90) t.end_fill() def drawRow(t,length,color1,color2): for i in range(4): drawSquare(t,length,color1) t.forward(length) drawSquare(t,length,color2) t.forward(length) def drawCircleFilled(t,size,color): t.fillcolor(color) t.begin_fill()...
python / visual studio
Problem 1: Random Walk A random walk is a stochastic process. A stochastic process is a series of values that are not determined functionally, but probabilistically. The random walk is supposed to describe an inebriated person who, starting from the bar, intends to walk home, but because of intoxication instead randomly takes single steps either forward or backward, left or right. The person has no memory of any steps taken, so theoretically, the person shouldn't move...
INSTRUCTIONS: I NEED TO CREATE A PointApp PROGRAM THAT USES THE FOLLOWING API DOCUMENTATION. Below the API Documentation is the code I submitted. However, the output is different for what they are asking. I am looking for someone to fix the code to print out the correct output and to add comments so I can have an idea in how the code works. PLEASE AND THANK YOU. API DOCUMENTATION: public class Point extends java.lang.Object The Point class is used to...
LANGUAGE: PYTHON
Write a function called: d_polybius(). The
function applies the decryption scheme for the polybius cipher
scheme above. The start of the function call the
get_polybius_square function to get the square as a
string.
The second scenario when the number of characters is not even,
excluding ‘\n’. For instance: “71\n5” is an invalid cipher because
there is no way that the last number correspond to a character (we
need two numbers).
A customized version of Polybius square will be...
C++ Fraction calculator Need help with code, cant use "using namespace std" Objectives Create and use functions. Use a custom library and namespace. Use reference variables as parameters to return values from functions. Create a robust user interface with input error checking. Use exceptions to indicate errors. Resources kishio.h kishio.cpp Assignment requirements You will need eight methods (including main). One is given to you. Their requirements are specified below: menu: The menu function takes no arguments, but returns a char...
I NEED HELP WITH DEBUGGING A C PROGRAM! PLEASE HEAR ME
OUT AND READ THIS. I just have to explain a lot so you understand
how the program should work.
In C programming, write a simple program to
take a text file as input and encrypt/decrypt it by reading the
text bit by bit, and swap the bits if it is specified by the first
line of the text file to do so (will explain below, and please let
me...
Q1. Write a recursive function in C++ void printNumberedChars(string str, int i=0) { ... } which prints each character of the given string str on a new line, with each line numbered 1, 2, 3, …. For example calling the function with printNumberedChars("hello"); should output the following: 1. h 2. e 3. l 4. l 5. o Q2. Write a recursive function in C++ int sumArray(const int* arr, unsigned int size) { ... } which takes an array of integers,...