Functions, Iterations and List Write a function that takes a positive integer n as its parameter. • Return a list whose o values are numbers between n and 2n.
Q: Write a function that takes list and a number (x) as parameters. Assume list contains only numbers,…
A: - We need to solve the number list problem in python.
Q: Write and test a function shuffle (my List ) that scrambles a list into arandom order, like…
A: Given: Write and test a function shuffle (my List ) that scrambles a list into arandom order, like…
Q: print_smallest_and_largest_even Write a function named (numbers_list) that takes a list of numbers…
A: Finding smallest and largest Even number from list using python
Q: Algorithm Efficiency 1- Programming Problem Part 1 Write a function that will have a list as an…
A: the answer is given below:
Q: 3. Write a function that takes in a list returns a new list with only the odd elements from the…
A: Note: we are only allowed to solve one question in one post.Since 1 and 2 are done I am solving the…
Q: Create a function that determines the elements in a list that can be rearranged to create a sequence…
A: Approach: Sort all the elements. Do a linear scan of the sorted array. If the difference between the…
Q: 6.28 LAB: Output values in a list below a user defined amount - functions Write a program that first…
A: The source code is: #declare the function get_user_values() def get_user_values(): #declare the…
Q: All Numbers in List Are Prime Published by mkjlong in Python - algebra math validation Create a…
A: Algorithm: Start Define a method which takes a list as its parameter Inside the method, Initialize…
Q: Design a function that accepts a list as an argument and returns the largest value in the list. The…
A:
Q: Write a function that will display the Doubly Linked List in reverse order
A: Provided a list of positive integers that are doubly linked The aim is to reverse the order of the…
Q: squares Write a function squares that accepts a 2-dimensional list of integers or a list of ranges…
A: The solution for the above given question is given below:
Q: get_column_choice(): this function will allow us to ask the players which pocket they want to grab…
A: Hey there, I am writing the required solution based on the above given question. Please do find the…
Q: 5.18 LAB: Smallest and largest numbers in a list Instructor note: Feel free to use Python's built-in…
A: Algorithm: Start Declare an empty list l Read numbers into the list till the is greater than 0…
Q: complete the following function. // It is the same as observeCounter except that f has a parameter…
A: // It is the same as observeCounterList except that f has a parameter of type Array[Counter] not…
Q: iv) Define a function in Python that takes a list as parameter and returns a new list that contains…
A: Write a Python program to define a function that takes a list as a parameter and returns a new list…
Q: Write a function that takes a nested list of integers and add up the elements from all of the nested…
A: For nested list, you can iterate over a list and then use sum function or you can iterate over that…
Q: a function maxCylinderVolume that takes a list of floating-point tuples that represent dimensions of…
A: F# system function such as min or methods in the list module such as List.map are not allowed Write…
Q: 3.9 LAB: Smallest and largest numbers in a list using min and max built-in functions NOTE1: Please…
A: This python program, initializes two lists.
Q: By use phython: Write a program to find words with less than 5 letters in a text and store them in a…
A: Python is an interpreted object oriented high level programming language with dynamic semantics. Its…
Q: Write a function that accepts a list as an argument (assume the list contains integers) and returns…
A: Let the function be called calculateSum.
Q: Implement the following: 1) Write a function randFive() with one parameter n. 2) randFive() create…
A: Python Code for the above scenario :
Q: Create a function find zeros that will... find the zeros of a function. To do this search a 10 × 10…
A: A quadratic function's method: That equation is as follows for a linear transformation. y = f(x) = a…
Q: ©given(lists(integers()), integers()) def test_append(1st: List, v: int): "H"Test that . .. # TODO:…
A: The code along with output screenshot and code screenshot
Q: 3. find_movies_by_director This function takes a list of tuples (representing movies) and a string…
A: According to the information given:- We have find-movie_by_director... from the given list we have…
Q: @given(lists(integers()), integers()) def test_append(lst: List, v: int): " H"Test that . . . #…
A: answer is
Q: 64. The function that follows makes use of a loop. Rewrite it so that it operates like a recursive…
A: ALGORITHM:- 1. Define the base case when size is equal to 0. 2. Pass one less value of size each…
Q: Guess a letter: w wallaby You win! # The program selects the word platypus Guess a letter: b…
A: The given python code is examined and the respective needed changes are done on the given code and…
Q: 16-Write a function called find_integer_with_most_divisors that receives a list of integers and…
A: Since the programming language is not specified in the question, so I am using python programming…
Q: A cyclist has several rides each day. After each ride she records the number of miles she has…
A: In the question it is given that cyclist has ridden different number of miles per day. So we
Q: Question 2: Nonzero Write a function that takes in a list and returns the first nonzero entry. def…
A: I have provided PYTHON CODE along with CODE SCREENSHOT and also provided OUTPUT…
Q: 3.8 LAB: Read values into a list Write a program that reads a list of integers into a list as long…
A: The above question is solved in step 2 :-
Q: Exercise 02 The call list (someString) transforms a string into a list of characters. Write the…
A: Step-1: Start Step-2: Call a function printAsString and pass list("hello") Step-3: function…
Q: An activity is carried out with many people, of which the only requirement of the activity is to be…
A: According to the guideline I need to answer only one question in a question but you asked 2…
Q: Write a recursive function that returns the largest integer in a list. Write a test program that…
A: Python Code: def main (): string= input("Enter numbers separated by spaces in a line: ")…
Q: 1. A list of numbers is said to be balanced if the sum of its first half is equal to the sum of its…
A: As per our company guidelines we are supposed to answer only one question per post and kindly…
Q: 4. Write a function remove_repetition that takes any list 1st and returns a new list with the same…
A: (1) Create an empty list called "res" (2)Loop through each element in the list (3) If the element is…
Q: python question: Write a code that takes a sentence as an argument and places its words in a list…
A: #method that takes sentence as argument and places its words#in a list in alphabetical order and…
Q: JS Write a function named find_value that takes a list/array of whole numbers as a parameter. Your…
A: I give the code in js(javascript ) and provide the output and code screenshot. I also provide the…
Q: Complete the calc_average() function that has an integer list parameter and returns the average…
A: Hi. Let's move on to the code in the next step. I have included comments in the code that will help…
Q: .Prime Numbers In this task, you will implement a program that takes as input a number n and…
A: Given, Pseudocode of isPrime() function: Step 1: count = 2Step 2: while count < numberStep 3: if…
Q: Using Clojure Write a procedure, called count-to-1, that takes a positive integer n, and returns a…
A: Language linguisticsThe artificial language has its own linguistics, that is however everything the…
Q: True or false? When a list is passed to a function, a new list is created and passed to the…
A: List List is used to store the multiple items in the single variable. Items in list are changeable,…
Q: Task 1- Random list of integers and computing the average Two functions you need to implement:…
A: Logic:- use randint from random to generate random number in range[start,end] append the generated…
Q: 6. list_n_perfect_squares This function takes a positive integer, n, and returns a list containing n…
A: Program: def list_n_perfect_squareslist_n_perfect_squares(n): # Calling function recieve n value…
Q: def removeMultiples(x, arr) - directly remove the multiples of prime numbers (instead of just…
A: Given: def remove multiples(x, arr) - directly remove the multiples of prime numbers (instead of…
Q: 1.3 dict_get Next, you will implement: char* dict_get (const dict_t* dict, const char* key); his…
A: Using the function Create a dictionary by c programming language. char* dict_get (const dict_t*…
Q: 4. Write a recursive function that calculates the sum of the integers in a recursive list. Name the…
A: here in the question ask for summation of integer in recursive list and give one function called…
Q: Create a Flowchart for this code. import random #Define a function to pick 5 numbers from 1 to 38…
A: The following is the flowchart diagram for above Python code:
Q: Problem Description A. Write a function named count_even(…) that receives as an argument a nested…
A: Kindly Note: As per our guidelines we are supposed to answer only one question. Kindly repost other…
Q: Complete the code for the following function so it matches its documentation: def…
A: def doubleList(numberList): #defining the function with list as a Parameter for num in…
Step by step
Solved in 2 steps with 1 images
- 1- Programming Problem Part 1 Write a function that will have a list as an input, the task of the function is to check if all the elements in the list are unique,( i.e. no repetition of any value has occurred in the list), then the function returns true otherwise it returns false. Your program should include a main method that call the method to test it. (If you would use built-in functions in Python, use lists’ or dictionaries’ methods as we studied their time efficiency in class)Write a function that returns the greatest common divisor (GCD) of integers in a list. Use the following function header:def gcd(numbers):Write a test program that prompts the user to enter five numbers, invokes the function to find the GCD of these numbers, and displays the GCD.Exercise, maxCylinderVolume F# system function such as min or methods in the list module such as List.map are not allowed Write a function maxCylinderVolume that takes a list of floating-point tuples that represent dimensions of a cylinder and returns the volume of the cylinder that has the largest volume. Each tuple has two floating point values that are both greater than zero. The first value is the radius r and the second value is the height h. The volume of the cylinder is computed using ??2h. The value π is represented in F# with System.Math.PI. If the list is empty, return 0.0. Examples: > maxCylinderVolume [(2.1, 3.4); (4.7, 2.8); (0.9, 6.1); (3.2, 5.4)];;val it : float = 194.3137888> maxCylinderVolume [(0.33, 0.66)];;val it : float = 0.2257988304
- Algorithm Efficiency 1- Programming Problem Part 1 Write a function that will have a list as an input, the task of the function is to check if all the elements in the list are unique,( i.e. no repetition of any value has occurred in the list), then the function returns true otherwise it returns false. Your program should include a main method that call the method to test it. (If you would use built-in functions in Python, use lists’ or dictionaries’ methods as we studied their time efficiency in class) 2- Algorithm AnalysisFor the function you implemented in part 1, please calculate T(n), which represents the running time of your algorithm in terms of n. Where n is the length of the list. Then find the order of magnitude of your algorithm (Big O). 3- Algorithms Comparison Please find another algorithm that solves part 1, write the code, calculate T(n) and find Big O. Then compare the efficiency with the algorithm from part1 to determine the more efficient one.Q1:Write a function that returns a new list by eliminating theduplicate values in the list. Use the following function header:def eliminateDuplicates(lst):Write a test program that reads in a list of integers, invokes the function,and displays the result. Here is the sample run of the program Enter ten numbers: 2 3 2 1 6 3 4 5 2The distinct numbers are: 1 2 3 6 4 5 Q2:Write a program that reads in your Q1 Pythonsource code file and counts the occurrence of each keyword in the file.Your program should prompt the user to enter the Python source code filename. This is the Q1: code: def eliminateDuplictes(lst):newlist = [] search = set() for i in lst: if i not in search: newlist.append(i) search.add(i) return newlist a=[] n= int(input("Enter the Size of the list:")) for x in range(n):item=input("\nEnter element " + str(x+1) + ":") a.append(item) result = eliminateDuplictes(a) print('\nThe distinct numbers are: ',"%s" % (' '.join(result)))***python only*** Write a function votes_by_race() which takes a list of dicts as a parameter and returns a dict. For example, given the following list: votes = [{'for': 'A, 'age': 35, 'race': 'w'}, {'for': 'B', 'age': 40, 'race': 'b'}, {'for': 'B', 'age': 20, 'race': 'b'}, {'for': 'A', 'age': 30, 'race': 'a'}, {'for': 'A', 'age': 41, 'race': 'w'}, ] The call votes_by_race(votes) should return the following dict:{"White": 2, 'Black': 2, 'Asian': 1, "Hispanic': 0}
- 16-Write a function called find_integer_with_most_divisors that receives a list of integers and returns the integer from the list with the most divisors .In the event of a tie, the first case with the most divisors returns .For example: If the list looks like this: [8, 12, 18, 6] In this list, the number 8 has four divisors, which are ;[1,2,4,8] :The number 12 has six divisors, which are ;[1,2,3,4,6,12] :The number 18 has six divisors, which are ;[1,2,3,6,9,18] :And the number 6 has four divisors, which are : [1,2,3,6]Note that both items 12 and 18 have the maximum number of divisors and are equal in number of divisors (both have 6 divisors) .Your function must return the first item with the maximum number of divisors ;Therefore it must return the following value: 12Question > Not complete Marked out of 1.50 Flag question Previous page Write a recursive function named get_palindromes (words) that takes a list of words as a parameter. The function should return a list of all the palindromes in the list. The function returns an empty list if there are no palindromes in the list or if the list is empty. For example, if the list is ["racecar", "hello", "noon", "goodbye"], the function should return ["racecar", "noon"]. A palindrome is a word that is spelled the same forwards and backwards. Note: The get_palindromes() function has to be recursive; you are not allowed to use loops to solve this problem. For example: Test words = ["racecar", "hello", "noon", "goodbye", "test", 'aibohphobia'] ['racecar', 'noon', 'aibohphobia'] print (get_palindromes (words)) print (get_palindromes ([])) print (get_palindromes (['this', 'is', 'test'])) Answer: (penalty regime: 0, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50 %) Result Precheck Check [] [] Next pageWrite the following function that tests whether the list has four consecutive numbers with the same value: def isConsecutiveFour(values):Write a test program that prompts the user to enter a series of integers and reports whether the series contains four consecutive numbers with the same value.
- ] ] get_nhbr In the cell below, you are to write a function called "get_nhbr(Ist, graph)" that takes in two inputs: a list of vertices and a graph. The function is to return a list that contains the neighborhood of the vertices in 'Ist' (remember that this means you are finding the union of the individual vertices' neighborhoods). + Code + Markdown After compiling the above cell, you should be able to compile the following cell and obtain the desired outputs. print (get_nhbr(["A", "D"], {"A" : ["B"], "B" : ["A", "D", "E"], "C" : ["E"], "D":["B"], "E":["B","C","F"], "F":["E"]}), get_nhbr(["B", "C", "F"], {"A" : ["B"], "B" : ["A", "D", "E"], "C" : ["E"], "D":["B"], "E":["B","C","F"], "F":["E"]})) This should return ["B"] ["A", "D", "E"] Python PythonTo determine if two lists of integers are equivalent, you must write a function that accepts the lists as input and returns true or false (i.e. contain the same values). The greatest value of each list must be shown if the lists are dissimilar and the procedure is effective.Common Time Zones Function Name: commonTimeZones() Parameters: code1( str ) , code2( str ) Returns: list of common time zones ( list ) Description: You and your friend live in different countries, but you figure there's a chance that both of you might be in the same time zone. Thus, you want to find out the list of possible time zones that you and your friend could both be in. Given two country codes, write a function that returns a list of the time zones the two countries have in common. Be sure not to include any duplicate time zones. If the two country codes do not have any common time zones, return the string 'No Common Time Zones' instead. Note: You can assume that the codes will always be valid. example test cases: >>> commonTimeZones('can', 'usa') ['UTC-08:00', 'UTC-07:00', 'UTC-06:00', 'UTC-05:00', 'UTC-04:00'] >>> commonTimeZones('rus', 'chn') ['UTC+08:00'] For this assignment, use the REST countries API…