Write 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.
Q: Write a function named remove_names (names_list) that takes a list of names as a parameter, and…
A: Answer to the given question: Python Program for the given question is : new_lst=[] def…
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: Write a function that returns the greatest common divisor (GCD) of integers in a list. Use the…
A: NOTE: SINCE THE LANGUAGE OF THE CODE IS NOT MENTIONED, I HAVE USED PYTHON FOR THE SOLUTION. Define…
Q: Prompt the user to enter a string of their choosing (assume no punctuation). Store the text in a…
A: Since the Programming language is not mentioned in the question, we will answer this question in…
Q: Functions, Iterations and List Write a function that takes a positive integer n as its parameter. •…
A: NOTE - Here I have used the Java programming language Here I have created a function named…
Q: python Write a function lottery() that simulates simple lottery program. This lottery program works…
A: import randomfrom operator import eqmenu_check = True# 'checker', compares userNums and winningNums…
Q: Write a function that returns a new list by eliminating the duplicate values in the list. Use the…
A: note: we are only allowed to solve one question in one post. please post-second question in a…
Q: Write a function for the user to enter a positive integer n with a value between 10 and 1000. If…
A: Q: As per bartleby policy, we can only answer one part per question. Please post other parts in a…
Q: Write a function randFive() with one parameter n. 2) randFive() create five random integers in the…
A: Steps to be followed: Import random module in the code. Take an empty list. Call function…
Q: Using Clojure Write a procedure, called count-to-n, that takes a positive integer n, and returns a…
A: The Clojure code is given in step 2.
Q: Problem Attached
A: ONLY FIRST THREE PARTS ARE SOLVED. KINDLY SEND THE REMAINING QUESTIONS ON THE PORTAL FOR THEIR…
Q: Write the following function that merges two sorted lists into a new sorted list: void merge(const…
A: solution is given below
Q: You can shuffle a list using random.shuffle(lst). Write your own function without using…
A: PROGRAM CODE: import random // import the random library def shuffle(lst):…
Q: listAverage() returns the average number in a list
A: Correct Answer The function listAverage() accepts a list as the argument and initialized the…
Q: Write the following function that returns true if the list is already sorted in increasing order:…
A: #include<iostream>using namespace std;bool isSorted(int arr[], int size){ for(int a=0;…
Q: Exercise #3 o Write a program averageLuminance(picture) which takes as input a picture uses…
A: Calculates image brightness by luminance per pixel. Extract each color components and calculate…
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: The reverse function in Section 10.8 reverses a list by copying it to a new list. Rewrite the…
A: In Python, lists are used to store multiple items in a single variable. Lists are mutable type its…
Q: Write the following function that returns true if the list is already sorted in increasing order:def…
A: In the given problem we will use python 3 code, def isSorted(list): for x in range(len(ll)-1):…
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: 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: Write a function void printSecond(ListNode *ptr) that prints the value stored in the second node of…
A: GIVEN: Write a function void printSecond(ListNode *ptr) that prints the value stored in the second…
Q: int foo(listL,int s) if (L.empty() ) return 0; if(s<L.size () ) { int t; L.retrieve (s,t); return…
A: Question: This code used to?
Q: Question 3: Contains N Write a function that takes in a list and a number, and returns whether or…
A: for searching a value in list use the in operator, which will return the Boolean value True, if the…
Q: The two-dimensional lists m1 and m2 are strictly identical if their corresponding elements are…
A: Program Approach: Create a boolean function which takes two matrices.Using for loop check whether…
Q: PYTHON CODE Write a function list3Digit10() that creates and returns a list that contain all…
A: Refer to step 2 for the answer.
Q: Write an application that accepts up to 20 Strings, or fewer if the user enters a terminating…
A: while (str.equals(sentinel) != true && count < 20) { if (str.length() <= 10) {…
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: The program requires me to remove all item for a list, but when doing the test case for it, it only…
A: Solution: I have analyzed you code and we found some mistake
Q: Write the following function that merges two sorted lists into a new sorted list: void…
A: #include <bits/stdc++.h>#include<algorithm>using namespace std;int merge_arrays(int…
Q: plete the following function according to its docstring using a while loop. The lists we test will…
A:
Q: Write a procedure called check_workday(check_day). The procedure should accept a single word as a…
A: Python allows to use of in and not in membership operators. They are used to test whether a value or…
Q: 1. You only want to watch low calorie food. Write the following function: def low_cal(foods, count)…
A: Python used to answer this question
Q: 1. Write a program called a2_q1.py that asks the user (business owner) for their product information…
A: The problem should start by asking the business owner’s name (string) and the name of the company…
Q: In a program, write a function that accepts two arguments: a list, and a number n. Assume that the…
A: Since programming language not mentioned using python.
Q: mplement a function void printAll(void) to print all the items of the list.
A: Here the pointer list is pointing to first node of listNode. The next node is accessed by using…
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: The two-dimensional lists m1 and m2 are identical if they have the same contents. Write a function…
A: Given: The two-dimensional lists m1 and m2 are identical if they have the same contents. Write a…
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: Implement the following function. 1. void listNumbersAsc(int start, int end);Description: Outputs…
A: Below is the implementation of the function: - Approach: - Define the function listNumbersAsc.(int…
Q: def recdif(lst): PRE: 1st is a list of 2 or more integers POST: returns the greatest absolute…
A: def recdif(lst): n = len(lst) if n <= 1: return 0 x = int(n/2) return…
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: The following program has a bug. What is it? def get data(ifile): myList = ] %3D for line in ifile:…
A: Explanation: In programming, methods are executed and get the return value. In the first…
Q: Write a function that accepts a list of numbers as it's only arguments. The function will return the…
A: I have provided PYTHON CODE along with CODE SCREENSHOT and 2 OUTPUT…
Q: Python write a program in python that plays the game of Hangman. When the user plays Hangman, the…
A: Python Code for word guessing game Hangman
Q: (Using Python)Write a function that returns a new list by eliminating the duplicate values in the…
A: Actually, python is a easiest programming language. It is a dynamically typed programming language.
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…
Write 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.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
- python question: Write a code that takes a sentence as an argument and places its words in a list of words in alphabetical order If the sentence is: "Am I good" The function returns: ['Am', 'I', 'good']C++ language Write a menu driven program which has following options:1. Factorial2. Prime or not3. Odd or even4. ExitOnce a menu is selected, the appropriate action should be taken and once this action is finished,the menu should reappear. Unless the user selects the ‘Exit’ option the program should continueto work.Note: Consider array of random numbers from user to find Prime Numbers/Odd/Even and userentered value for factorial.Topics: User-defined functions, list, string, docstringProblem Statement: This program finds the unique letters from a given string and printsthe unique letters and their count. For example: word ‘LITTLE’ has ‘L’, ‘I’, ‘T’, ‘E’ are theunique letters.Lab Scenario:The program repeats until hits ‘n’. The program takes a user input of a string. The programfinds the unique letters in the string, add them in a list and displays the list and their count.Consider the following important points:1) You need to design a user-defined function named count_unique_letters whichtakes user word as parameter and returns the list of unique letters calledunique_letters in the given word.a. Hint: Iterate over each letter in user word, check if the letter is in the list, if notadd it to the list, otherwise continue to the next letter. A ‘in’ keyword can helpto determine if a character in the unique_letters list.b. You need to write a simple docstring for this function.2) Your program must have a main()…
- Brussel's choice def brussels_choice_step(n, mink, maxk): This problem is adapted from another jovial video "The Brussel's Choice" of Numberphile (a site so British that you just know there has to be a Trevor and a Colin somewhere in there) whose first five minutes you should watch to get an idea of what is going on. This function should compute and return the list of all numbers that the positive integer n can be converted to by treating it as a string and replacing some substring m of its digits with the new substring of either 2*m or m/2, the latter substitution allowed only when m is even so that dividing it by two produces an integer. This function should return the list of numbers that can be produced from n in a single step. To keep the results more manageable, we also impose an additional constraint that the number of digits in the chosen substring m must be between mink and maxk, inclusive. The returned list must contain the numbers in ascending sorted order.Python question Application: Python Fragment Formulation (Q1 – Q4) In this group of questions you are asked to produce short pieces of Python code. When you are asked to "write a Python expression" to complete a task, you can either give the expression in one line or break down the task into several lines. The last expression you write must represent the required task. Question 1 (Reduce parentheses) Give an equivalent version of this expression by removing as many redundant parentheses as possible, without expanding the brackets or simplifying. (x**(2**y))+(y*((z+x)**3)) Question 2 (Translate arithmetic concept into Python) You are given a list of numbers, named numbers, containing 3 integers. Write a python expression (one line) that evaluates to True if and only if the product of any two numbers in the given list is greater than the sum of all three numbers. Note: the product of two numbers, x and y is x*y. Question 3 (List/table access) You are given a table,…python exercise: 1. Write a Python function called generate_quiz_question that takes a list of quiz questions (represented as tuples of the question and answer) as input and returns a randomly selected question from the list. The function should also prompt the user to enter their answer to the question, and then check whether the user's answer is correct or not. If the user's answer is correct, the function should return True. Otherwise, it should return False. 2. Write a function is_palindrome(s) that takes a string s as input and returns True if s is a palindrome (i.e., reads the same backwards and forwards), and False otherwise 3. Write a Python function called get_top_students that takes the list of dictionaries as input and returns a dictionary containing the name and GPA of the top two students in the list. Each dictionary has the following keys: "name", "age", "major", and "gpa".
- Cyclops numbersdef is_cyclops(n):A nonnegative integer is said to be a cyclops number if it consists of an odd number of digits so that the middle (more poetically, the “eye”) digit is a zero, and all other digits of that number are nonzero. This function should determine whether its parameter integer n is a cyclops number, and return either True or False accordingly n Expected result 0 True 101 True 98053 True 777888999 False 1056 False 675409820 False2- The factorial n! of a positive integer n is defined as n! = 1*2*3 . .. * (n-1) * n Where 0! = 1 Write a function to calculate the factorial of a number. Argument: A number n of type unsigned int. Returns: The factorial n! of type long double. Write two versions of the function, where the factorial is • calculated using a loop calculated recursively Test both functions by outputting the factorials of the numbers 0 to 20.Ex1: a) Write a function for the user to enter a positive integer n with a value between 10 and 1000. If entered correctly, the function generates a list containing n random values that do not overlap between 1 and 5000 and the function returns the newly created list. Conversely, if entered incorrectly, the program will ask to re-enter until it is correct. Cases where n is considered incorrect:(i)- If the user enters a non-integer data type (like string, float, bool, ...)The program will display the error message 'Must enter a positive integer. Requires re-entry'.(ii)- If the input value is of the correct integer data type but the value is not in the range10 to 1000, the program gives the error 'Only values between 10 and 1000. Re-enter required'.Installation requirements: must use the try ... except statement to handle possible exceptionsin the program. b) Write a function that lists the amicable numbers in the list just created in a) (If there are no amicable numbers in the list,…
- 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…*Coding language is Python Write a program that opens the productsales.txt file and reads the sales into a list. The program should output the following information, in this order: The total of all sales in the list The average of all sales in the list The lowest sale in the list The highest sale in the list NOTE: Your program should include at least one user-defined function, in addition to the main function. 4147 1594 2235 8433 10000 129 5555 7030 9764 7465 1111 4444 8954 2243 2895 1436 4978 5486 1436 9846 4789 8456 2497 2280 6375Common 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 (https://restcountries.com/#api-endpoints-v2). For all of your requests, make…