1. count_perfect_squares This function takes a single argument, nums , Which is a list of numbers. The function counts up how many of the numbers in the input list are "perfect squares", which is to say that they are a square of an integer. Sample calls should look like this: >>> count_perfect_squares ([2, 3, 4, 16, 10e, 5, 1]) 4 >>> count_perfect_squares([]) >>> count_perfect_squares([13])
Q: Python: On-line Grocery Shopping Use grocery py in Canvas to start your program. It contains two…
A: Answer: Code: food = ["tomato_soup", "cheese", "sauce", "chicken"] stock = {"tomato_soup": 20,…
Q: You have been hired as an app developer for the company. The company plans to make an app for a…
A: Iterate over given list of order_items If item present in map, add its price to total Finally add…
Q: If you have the following node declaration: struct Node { int number; struct Node * next; }; typedef…
A: C program to create all the required functions for the linked list.
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: paython programing question Write a program that creates a list of N elements (Hint: use append()…
A: Note: Code comments have been added in the source code itself to have a better understanding of the…
Q: Part 1.2: Big bOx Functions You are given two functions which are used in sequence as shown below.…
A: The Answer is
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: Python Programming: 2D list The Lo Shu Magic Square is a grid with 3 rows and 3 columns that…
A: Actually, array is a collection of elements.
Q: Given snippet code below that you are required to complete. You are not allowed to make a new…
A: #include <stdio.h>#include <conio.h>#include <malloc.h>struct node {int key;struct…
Q: Use C language only. Create a program that will ask for Enter number of students: (for this…
A: Summary: In this question, we have been given one program, in that program, there are three…
Q: Programming in C.
A: Algorithm: Declare required header files.Create “ContactInfo” structure.Declare required variables…
Q: Task 2- Phone number input -> to character list -> to word list Two functions you need to implement:…
A: 1) Program to take a phone number from user and convert it into character and word list and display…
Q: 5. Declare a set named vowels containing the strings 'a','e','i','o', 'u'. Create a function called…
A: As per Bartleby's policy, only 1st question can be solved for multiple questions. Please post the…
Q: This assignment is about temperatures and requires the main function and a custom value-returning…
A: A required program is as follows, import random '''Define a function that returns a smallest list of…
Q: Python: On-line Grocery Shopping Use grocery py in Canvas to start your program. It contains two…
A: Python used to answer this question
Q: (python) prov_vac_status() takes a 2-D list (similar to the database) and an integer representing…
A: Hey there, I am writing the required solution of the questin mentioned above. Please do find the…
Q: If you have the following node declaration: struct Node { int number; struct Node * next; }; typedef…
A: According to the policy, only the first 3 questions has been answered. The remaining questions can…
Q: 6. sum_highest_five This function takes a list of numbers, finds the five largest numbers in the…
A: def sum_highest_five(L): # function to return sum of five highest numbers in a list s = 0…
Q: You have been hired as an app developer for the company. The company plans to make an app for a…
A: According to the Question below the Solution: Program Output:
Q: Sales Data Program Create a successful running c++ program that meets the following requirements.…
A: ************* something to note ***************In the program i had created the add function as…
Q: Python Code: Use def functions. Please upload the code. Thank you. Stop when and only when the…
A: ANSWER:-
Q: Return Growing NumList This function will be given a single number, it should return a list of…
A: The Answer is in Below Steps
Q: CH7: Problem 1: Lo Shu Magic Square 15 The Lo Shu Magic Square is a grid with 3 rows and 3 columns,…
A: Python code: def generateSquare(n): # 2-D array with all # slots set to 0 magicSquare = [[0 for x…
Q: This assignment requires the main function and a custom value-returning function. The…
A: random.randint(200,250) : function imported using "import random" module, returns a random number…
Q: You have been hired as an app developer for the company. The company plans to make an app for a…
A: In python list is a data structure that is used for storing multiple data values in a single…
Q: Common Time Zones Function Name: commonTimeZones() Parameters: code1( str ) , code2( str )…
A: Hey there, I am writing the required solution of the questin mentioned above. Please do find the…
Q: ndng 2. Modular Programming: Your program should be modular and consists of the following functions:…
A: the code is an given below : Raw_Code: def read():#prompting and reading Z value from userZ =…
Q: rite a procedure (intercalate sep lst) where sep is a string and lst s a list of strings that…
A: Python code :- sep=("I","Love","functional","programming")x=" ".join (sep)print (x)…
Q: PS: Do not use regular expressions or built in function. Please answer it according to the…
A: Python code: def operateList(A, n): even = [] odd = [] for i in range(n): if ((i % 2) == 0):…
Q: Use the function design recipe to develop a function named count_odds. The function takes a list of…
A:
Q: Practice 2 class MedianFinder { /** initialize your data structure here. */ Median is the middle…
A: Below is the code and output:
Q: Function Name: commonTimeZones() Parameters: code1( str), code2( str) Returns: list of common time…
A: Hey there, I am writing the required solution of the questin mentioned above. Please do find the…
Q: PYTHON without Def funciton Problem Statement In Pascal's triangle, each number is the sum of the…
A: Since on top you have mentioned PYTHON without Def function, I have written the code without…
Q: sum_highest_five This function takes a list of numbers, finds the five largest numbers in the list,…
A: In this question, we are asked to write a sum_highest_five() funtion in python which will print the…
Q: If you have the following node declaration: struct Node { int number; struct Node * next; }; typedef…
A: Struct node:- A node is a struct with at least a data field and a reference to a node of the same…
Q: program7.py This assignment requires the main function and a custom value-returning function. The…
A: Custom function fun7(): Takes a list of random integers as its argument A loop is used to iterate…
Q: Question: Create a function that takes a tuple and returns a dictionary which is a histogram for…
A: Code:- # function definitiondef histo_n(x): dictr={} # ieterates through each element in the…
Q: Sample run Your program must define and use the following functions only: 1. read(): reads the city…
A: the code is an given below : def read(): cities = [] tempAvg = [] n =…
Q: If you have the following node declaration: struct Node { int number; struct Node * next; }; typedef…
A: Program code: #include <stdio.h> #include <stdlib.h> //struct store linked list node…
Q: Task 2- Adjacent element swap for a list (Topics: list, loops, functions, string manipulation,…
A: Solution: Given,
Q: 2. ID: A Name: 2. A list of numbers is considered increasing if each value after the first is…
A: List: List is used to store a collection of similar data types. List items is written in square…
Q: Need help with sml programming language. I need to define a function called countNegative (val…
A: Coded using SML.
Q: program7_1.py This assignment is about temperatures and requires the main function and a custom…
A: Below is the required program in python: Program Approach: Importing module random as we are…
Q: 6. Binary Search [Problem description] Given the grade list of students in a class and your grade,…
A: Binary Search: Search in a sorted array by repeatedly dividing the search interval in half. Begin…
Q: interleaved Write a function interleaved that accepts two sorted sequences of numbers and returns a…
A: #function interleaved takes two sorted lists, then returns a sorted sequence of all numbers by…
Q: OCAML programming Pascal triangle Write a function val nextpascalrow : int list -> int…
A: Program CatalanNumberstype tElement = Uint64;var Catalan : array[0..50] of tElement;procedure…
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: Complete the display_coins_list(coins_list) function. This function takes a list (always nine…
A: Asked python program is given in the next step using for loop.
Q: program7.py This assignment requires the main function and a custom value-returning function. The…
A: Below is the complete solution with explanation in detail for the given question in Python…
Q: 5. Dictionary-Returned Function a) Define a function, dictSqrt() with a parameter, x: 1) Create a…
A: Given that, Dictionary-Returned Function a) Define a function, dictSqr() with a parameter, x:…
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
- Python please! Generalized image blender function Create a function blend images() which takes multiple RGB images as an input, and outputs a blended image. The function should accept following parameters 1. image list- A Python list of 3D arrays where each 3D array corresponds to an RGB image 2. weight list-A Python list of float values between (0, 1) corresponding to the pixel weight to be given to each image-e.g. [0.2, 0.3, 0.1, 0.4] for 4 images. The sum of the weights should be equal to 1. Test your function against a provided list of 5 images with following weight lists (i.e. 2 blended images) [0.2, 0.2, 0.2, 0.2, 0.2]- blend all 5 images [0.2, 0.3, 0.5]- blend first 3 images NOTE: DO NOT USE pre-existing image blending functions.onsider an input string TAM of letters ‘A’, ‘M’, and ‘T’. This string, which is given by the user, ends with ‘#’. It should be stored in a table (or array), called TAMUK. The number of each of these letters is unknown. We have a function, called SWAP(TAM,i,j), which places the ith letter in the jth entry of string TAM and the jth letter in the ith entry of TAM. Note that SWAP(TAM,i,j) is defined for all integers i and j between 0 and length(TAM)–1, where length(TAM) is the number of letters of TAM. 1. Using our algorithmic language, write an algorithm, called Sort_TAM, which sorts the letters in the array TAMUK in a way that all T’s appear first, followed by all A’s, and followed by all M’s. The algorithm Sort_TAM should have one parameter: The array TAMUK. Also, your solution is correct only if the following four constraints are satisfied: - Constraint 1: Each letter (‘A’, ‘M’, or ‘T’) is evaluated only once. - Constraint 2: The function SWAP(TAM,i,j) is used only when it is…- Question-2: 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.
- Easy C++ program please answer fast Maximum Subarray Sum Rabbit Jerry downloads the list of N (2 ≤ N ≤ 105 ) stock prices of RABJ and stores them into a circular buffer/array in a clockwise manner (i.e., the first stock price follows the N-th stock price on the circular buffer) starting from index position 0. It is worth pointing out that the stock prices can be negative numbers in the rabbit stock market. He is curious about the maximum subarray sum over this circular buffer. Certainly, the maximum subarray can possibly straddle over both index positions 0 and N-1. Output the maximum subarray sum. The maximum subarray must contain at least one element. INPUT FORMAT (input arrives from the terminal / stdin): First line contains N. The next line contains N space-separated integers denoting the input sequence. The price ranges from -1,000,000 to 1,000,000. OUTPUT FORMAT (print output to the terminal / stdout): A single line containing the maximum subarray sum. Note that the output can…Two arrays list1 and list2 are strictly identical if they have the same length and list1[i] is equal to list2[i] for each i. Write a function that returns true if list1 and list2 are strictly identical using the following header: bool strictlyEqual(const int list1[], const int list2[], int size) Write a test program that prompts the user to enter two lists of integers and dis- plays whether the two are strictly identical. The sample runs follow. Note that the first number in the input indicates the number of the elements in the list. This number is not part of the list. Assume the list size is maximum 20.Two arrays list1 and list2 are identical if they have the same contents. Write a function that returns true if list1 and list2 are identi- cal using the following header: bool isEqual(const int list1[], const int list2[], int size) Write a test program that prompts the user to enter two lists of integers and dis- plays whether the two are identical. Here are the sample runs. Note that the first number in the input indicates the number of the elements in the list. This number is not part of the list. Assume the list size is maximum 20.
- ] ] 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 PythonRecamán's sequence def recaman(n): Compute and return the first n terms of the Recamán's sequence, starting from the term a1 = 1.Note how the definition for the current next element depends on whether a particular number is already part of the previously generated part of the sequence. To let your function execute in a speedy fashion even when generating a sequence that contains millions of elements, you should use a set to keep track of which values are already part of the previously generated sequence. This way you can generate each element in constant time, instead of having to iterate through the entire previously generated list. The better technique that saves time by using more memory can create this list arbitrarily far in linear time, and should therefore be fast even for millions of elements, at least until it runs out of memory. n Expected result 10 [1, 3, 6, 2, 7, 13, 20, 12, 21, 11] 1000000 (a list of million elements whose last five elements are [2057162,1057165,…Write a function that displays an n-by-n matrix using the following header: void printMatrix(int n)Each element is 0 or 1, which is generated randomly. Write a test program that prompts the user to enter n and displays an n-by-n matrix.
- Please answer with a proper explanation with output. Basic python class. Create a function using a for loop to count number of times a number less than or equal to 33 occurs. Test function on the following numpy array. random_list = np.array([19, 29, 33, 34, 30, 32, 42, 40, 35, 25, 24, 19, 35, 26, 39, 21])___________________________________________ def random_count(random_list):for i in random_list:if i <= 33:print(np.sum(i)) This is what I've done, but I can only get it to list out the individual numbers, but i want it to total them up.def fun_a(cards): """ cards is a list of int numbers ranging between 0 to 12 inclusive. We use the number to represent the card's rank in a deck of card. 0 is '2', 1 is '3', ...,9 is 'J', 10 is 'Q', 11 is 'K' and 12 is 'A' This function is to check if there is four of a kind in the cards (4 cards of the same rank) and a fifth card as a kicker to form a four of a kind hands with 5 cards total. The 5 cards look like this: x x x x y (x might be the same as y). If there is more than one way to form such a hand with given cards, choose x that has the highest ranking (that has 4 cards of rank x), and choose y that has the highest ranking in the remaining cards after removing 4 x's. return (x, y) if such a hand exists. otherwise return None. """Q4. Write a program that read 2 matrices and has a function which finds their sum. Q5. Write a program that read 2 matrices and has a function which finds their multiplication. Q6. Write a program that handles a list of numbers where it has the following functions - Function that finds their average and sum - Function that finds their maximum and minimum - Function that search for a given number in that list. - Function that count the occurrence of a given number in that list. Then the program should do the following: - Read the list - Find the average and the sum of that list - Find the minimum and the maximum of that list - Count the occurrence of a given number in that list.