The following
TestValue = first list entry
CurrentEntry = first list entry
while (CurrentEntry is not the last entry):
if (CurrentEntry > TestValue):
TestValue = CurrentEntry
CurrentEntry = the next list entry
Want to see the full answer?
Check out a sample textbook solutionChapter 5 Solutions
Computer Science: An Overview (12th Edition)
Additional Engineering Textbook Solutions
Starting Out with Python (4th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Thinking Like an Engineer: An Active Learning Approach (4th Edition)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
INTERNATIONAL EDITION---Engineering Mechanics: Statics, 14th edition (SI unit)
Database Concepts (8th Edition)
- 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.arrow_forwardThe program will take in a year as an input from the user and output the popular dance and popular slang from that decade. Years, slang, and dances are stored in parallel lists in the starter code. The decade 1920 is located at index 0 and accompanies the 1920’s slang and dance also located at index 0, the decade 1930 is located at index 1 and accompanies the 1930’s slang and dance also located at index 1, etc. year_list = list(range(1920, 2030, 10)) slang_list = ["bee's knees", "hip", "cool", "nifty", "groovy", "far out", "gnarly", "phat", "sweet", "lit", "fire"] dance_list = ["The Charleston", "The Jitterbug", "The Lindy Hop", "The Hand Jive", "The LocoMotion", "The Electric Slide", "The Moonwalk", "The Macarena", "Single Ladies", "Juju on that Beat", "The Renegade"] year = int(input("Year: ")) decade_index = (year - 1920) // 10 if decade_index == 11: print(f"In the {year_list[decade_index]}'s, The {dance_list[decade_index]} is the hip dance craze!") else:…arrow_forwardWrite the following function that returns true if the list is already sorted in increasing order:def isSorted(lst):Write a test program that prompts the user to enter a list and displays whether the list is sorted or not.arrow_forward
- A chain letter starts with a person sending a letter out to 10 others. Each person is asked to send the letter out to 10 others, and each letter contains a list of the previous six people in the chain. Unless there are fewer than six names in the list, each person sends one dollar to the first person in this list, removes the name of this person from the list, moves up each of the other five names one position, and inserts his or her name at the end of this list. If no person breaks the chain and no one receives more than one letter, how much money will a person in the chain ultimately receive? O 10,000 dollars O 1,000,000 dollars O 500,000 dollars O 100,000 dollarsarrow_forwardJava - Normalizingarrow_forwardQUESTION 4 This is a MULTIPLE ANSWER question, which means you are able to select one or more answers as being correct. Note that this does not necessarily mean that there are multiple correct answers. In any case, select all the answers you believe are correct. (NB: There are no part marks awarded for multiple answer questions.) There is a non-empty Python list of integers called numbera whose values are all in the range -maxaize to maxaize, inclusive. The following piece of code causes the SMALLEST value in list numbers to be stored in the variable answer: best - maxsize t a very large integer for number in numbers: if number number: t a very large integer best = number answer = best + a very small integer best - -maxsize for number in numbers: if best best: best = number answer= best best = -maxsize * a very small integer for number in numbers: if best > number: best - number answer bestarrow_forward
- The function interleave_lists in python takes two parameters, L1 and L2, both lists. Notice that the lists may have different lengths. The function accumulates a new list by appending alternating items from L1 and L2 until one list has been exhausted. The remaining items from the other list are then appended to the end of the new list, and the new list is returned. For example, if L1 = ["hop", "skip", "jump", "rest"] and L2 = ["up", "down"], then the function would return the list: ["hop", "up", "skip", "down", "jump", "rest"]. HINT: Python has a built-in function min() which is helpful here. Initialize accumulator variable newlist to be an empty list Set min_length = min(len(L1), len(L2)), the smaller of the two list lengths Use a for loop to iterate k over range(min_length) to do the first part of this function's work. On each iteration, append to newlist the item from index k in L1, and then append the item from index k in L2 (two appends on each iteration). AFTER the loop…arrow_forwardDomino cycledef domino_cycle(tiles):A single domino tile is represented as a two-tuple of its pip values, such as (2,5) or (6,6). This function should determine whether the given list of tiles forms a cycle so that each tile in the list ends with the exact same pip value that its successor tile starts with, the successor of the last tile being the first tile of the list since this is supposed to be a cycle instead of a chain. Return True if the given list of domino tiles form such a cycle, and False otherwise. tiles Expected result [(3, 5), (5, 2), (2, 3)] True [(4, 4)] True [] True [(2, 6)] False [(5, 2), (2, 3), (4, 5)] False [(4, 3), (3, 1)] Falsearrow_forwardWrite a function that takes a nested list of integers and add up the elements from all of the nested lists.arrow_forward
- 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 (https://restcountries.com/#api-endpoints-v2). For all of your requests, make…arrow_forwardCommon 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…arrow_forwardRewrite the following function using a while loop: def sum_of_list(lst): """Docstring: rewrite the sum of all values in a list Parameters: lst: a list of numbers Return: a number """ sum = 0 for item in lst: sum *= item return sumarrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning