CODE IN FUNCTIONAL PROGRAMMING LANGUAGE : PYTHON:
def sumGreaterThanVal(inputList, number): if len(inputList) == 0: return 0 if len(inputList) == 1: if inputList[0] > number: return inputList[0] return 0 if inputList[0] > number: return inputList[0] + sumGreaterThanVal(inputList[1:], number) return sumGreaterThanVal(inputList[1:], number) print("sumGreaterThanVal([9, 2, 4, 8], 5) : ", sumGreaterThanVal([9, 2, 4, 8], 5)) print("sumGreaterThanVal([9, 2, 4, 8], 11) : ", sumGreaterThanVal([9, 2, 4, 8], 11))
INDENTATION:
![def sumGreaterThanval(inputList, number): if len(inputList) == 0: return if len(inputList) == 1: if inputList[@] > number: re](http://img.homeworklib.com/questions/2edcac70-5f7c-11ec-8271-61eb5ba75712.png?x-oss-process=image/resize,w_560)
OUTPUT:
![Sum x C:\Users\madhu\venv\Python3.8\Scripts\python.exe D:/PythonWorld/HelloWorld/Sum.py sumGreaterThanVal([9, 2, 4, 8], 5) :](http://img.homeworklib.com/questions/2f385260-5f7c-11ec-9079-29ff85d3f5da.png?x-oss-process=image/resize,w_560)
Write a function either in a functional language or in Java but not using any variables...
Using Java: 1. Recursive Multiplication Write a recursive function that accepts two arguments into the parameters x and y. The function should return the value of x times y. Remember, multiplication can be performed as repeated addition as follows: 5×6=6+6+6+6+6 2. Recursive findings Write a recursive boolean method named reFinding. The method should search an array for a specified value, and return true if the value is found in the array, or false if the value is not found in...
Note: Please write the Pseudocode using Arrays method in Java language. Program 2 (40%); For this assignment, we're going to make a game. Imagine you initially start with a random "hand" of two cards (values 2-9). Your goal is to continue to add to your hand until the sum of the cards is between 21 25, at which point youu win. Further, if you hold 5 cards, you win. However, if you exceed a sum of 25, you lose. Admittedly,...
Need help with a few questions! Using the JAVA language please. 1) exercises - branching Write a method whatToWear(int temp) that takes a temperature and then outputs a string for what to wear in different weather conditions. There must be at least 3 categories. For example, whatToWear(90) might return “shorts” and whatToWear(30) might return “down coat” 2) Enum exercise • Define an enum Seasons, and rewrite the whatToWear method to use enums and switch statement 8) 2D array exercise 1....
Java language
Any use of java.util.LinkedList is prohibited
Objective: The goal of this assignment is to practice recursion. ignment: The assignment requires writing recursive methods for some linked list operations. The use of loops in the recursive methods is strictly prohibited in this assignment. That is, you cannot use for, while, and do-while in the recursive methods you will write. You can only use a loop when you will initiate values for a linked list in the main method. You...
Write java code to create 3 methods that accomplish the below concepts according to simple number theory. 1. Create a file PositiveInteger.java that houses a class called PositiveInteger 2. This class should have one single instance variable called num This is what I have for the constructor: public PositiveInteger(int number) { num = number; } The three methods should start with the italicized sections shown below to accomplish the corresponding tasks: 1. public boolean isPerfect () - A number is...
Java 8
9m left Jav 27 28 ALL 29 0 Given an integer array, separate the values of the array into two subsets, A and B, whose intersection is null and where the addition of the two subsets equals the entire array. The sum of values in set A must be strictly greater than the sum of values in set B, and the number of elements in set A must be minimal. Return the values in set A in increasing...
Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. A. Write a function named smaller that accepts two arguments: a list, and a number n. Assume that the list contains numbers. The function should display all numbers in the list that are smaller than the number n. Write a code that declares and initializes a list of numbers and a variable number and pass them to the function to test it. Please see the outcome below:...
Write the function in python and show the code
2. Write a function jscore (s1, s2) that takes two strings s1 and s2 as inputs and returns the Jotto score of s1 compared with s2 -.e., the number of characters in s1 that are shared by s2. The positions and the order of the shared characters within each string do not matter. Repeated letters are counted multiple times, as long as they appear multiple times in both strings. For example...
1 write a Python function that takes in a list of integers and returns maximum and minimum values in the list as a tuple. Hint (can be done in one pass, you are not allowed to use built-on min and max functions.)max, min = find_max_min(my_list):2 write a Python function that takes in a list of integers (elements), and an integer number (num). The functions should count and return number of integers in elements greater than, less than, and equal to...
Write the code in java programming language To get some practice with recursion. You can do all this in one driver program. Write a recursive method to compute the result of the Fibonacci sequence: Fibonacci(N) = Fibonacci(N -1) + Fibonacci(N-2) N == 0 is 0 N == 1 is 1 Testing: Display the result for Fibonacci(N) and the number of function calls for N = 2, 5 and 10.