1. The maximum difference between any two subsequent (right next to each other) numbers in the list 2. The longest increasing section of the list. For example, in the sequence 5, 1, 2, 19, 9, 20, the longest increasing section is: 1, 2, 19. (The 20 is not included in this section since it doesn't come immediately after the 19.) Here is a sample run of the program (user input is in red): Enter a list of numbers separated by spaces: 5 1 2 19 9 20 Maximum difference: 2 and 19 ing section:
Q: PYTHON
A: def sumInput(): mylist = [] whileTrue: num = float(input('\nPlease enter a positive number or…
Q: 1. Import the random module I want to generate random R, P, S. 2. Create a list After the game is…
A: Here is the explaination :- First create the function to generate the computer choice . Use random…
Q: Write a program that will iterate through the first loop and for each iteration, it will iterate…
A: Code is: numSet = [1,2,3] #list of numberalphaSet = ['A', 'B', 'C'] #list of alphabetsfor num in…
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: 5.20 LAB: Adjust values in a list by normalizing When analyzing data sets, such as data for human…
A: We have to write a program to adjust the values by dividing all values by the largest value. The…
Q: 2. Write a program that sums up all positive user input numbers. a) For every iteration output the…
A: def sumInput(num): if(num>=0): # storing the incoming value in a list…
Q: PROBLEM 7 Write a program that prompts the user to input two integers and prints a list of all the…
A: ALGORITHM:- 1. Take input for both the numbers. 2. Traverse for all the numbers until the smaller of…
Q: Write a program that first gets a list of integers from input. The input begins with an integer…
A: #include<iostream> #include<vector> using namespace std; vector<int>…
Q: add a grade to a list using the grade average code below. Then print the list with a print statement…
A: print("What was your test grade? or 999 to quit")grade1 = float(input()) list = [] sum = 0count = 0…
Q: Only authorized shareholders are allowed to attend a stockholders’ meeting. Write a program to read…
A: #include<iostream>#include<string.h> using namespace std; int main(){ int n,k=0;…
Q: python question Implement the following: 1) Create a list comprehension of multiples of 5 from 5 to…
A: l=[5,10,15,20,25,30,35,40,45,50]print(l[:3])#prints first three valuesprint(l[5:])#prints last five…
Q: When an employee is hired they get a set starting salary. Every year the salary grows by 4%. In the…
A: Question 1. When an employee is hired they get a set starting salary. Every year the salary grows by…
Q: Use the primes function to create a list of all the primes below 100. Now use a for loop to multiply…
A: The following is the MATLAB code to create a list of all the primes below 100 using primes function…
Q: Complete the binary search function below using while loop. int search(int a[], int t,…
A: GIVEN: Complete the binary search function below using while loop. int search(int…
Q: 14.2 (Python Please) (Count occurrences of numbers) Write a program that reads an unspecified…
A: here in this question we have asked to write a program which take a list of integer and output the…
Q: Use a for loop and the list append method to generate the powers of 2 to produce the following…
A: Hey there, I am writing the required solution based on the above given question. Please do find the…
Q: P3 – Inverted Pyramid of Odd Numbers 1. Write a program that prompts the user to enter an integer…
A: Q: Code the given pattern
Q: Exercise 2: A simple bar chart A bar chart is a good choice when you want to show how some quantity…
A: Matplotlib is used to draw graphical visuals in python programming language. A bar chart shows…
Q: After executing the following code segment the value stored in the variable "x" will be_ int…
A: Value stored in the variable x Code segment is also known as text segment and is a portion of an…
Q: The top 3 most popular male names of 2017 are Oliver, Declan, and Henry according to babynames.com.…
A: add is the method available in python to add an element to a set remove is the element available in…
Q: Given list below: odds = [1, 3, 5, 7, 9] Use a for loop to print out the values of each list item…
A: Python code is : odds = [1,3,5,7,9]for a in odds: print(a,a-1) A screenshot of the output is…
Q: 4. Use NumPy to write a program to generate a list that contain 5 random integers in the range 1 to…
A: Use NumPy to write a program to generate a list that contains 5 random integers in the range 1 to…
Q: Create a program that reads the total monthly sales for an entire year. The program outputs the…
A: Store all the months name in a list Now, input all the sales for each month Now find the average and…
Q: Write aPYTHON program that: asks the user to input() names one at a time, adds each new name to a…
A: In this program, we will create a while loop that will break only if the user will enter "FINISHED".…
Q: Iterative Fibonacci (while loop, perils of integer arithmetic) The Fibonacci sequence defined by…
A: Please refer below for your reference: Language used is MATLAB:
Q: Exercise 4: Write a program (Lab8_ex4_ld.py) that generates a random even positive integer less than…
A: Here is Your Code import randomh = random.randint(1, 10)print("Genarated Length = ",h)for i in…
Q: Given numRows and numColumns, print a list of all seats in a theater. Rows are numbered, columns…
A: 1. Taking variable i and x for iterating in loops . 2. Using the for loop and checking if i is less…
Q: 1. Write a program to generate the numbers from 0 to 5, display the result using List Box.
A: Program Approach: Import Tkinter module Create an object of Tkinter, root. Create a Listbox,…
Q: Pizzas: Think of at least three kinds of your favorite pizza. Store these pizza names in a list,…
A: Here we use simple python programming:…
Q: Exercise 4: Write a program (Lab8_ex4_ld.py) that generates a random even positive integer less than…
A: code :-- # for genrate random module import random# genrate random even number between 0 to 10…
Q: Exercise 6.19 gives a function for testing whether three points are on the same line. Write the…
A: GIVEN: A function for testing whether three points are on the same line. Write the following…
Q: Design a program that generates a seven-digit lottery number. The program should generate seven…
A: Since programming language not mentioned using python language.
Q: . Modify that program so that any number of responses can be entered, and the user does not have to…
A: I just changed the for loop to enter values till we get 999 as a response. For this just used a…
Q: Using two lists. numSet = [1,2,3] alphaSet = ['A', 'B', 'C'] Write a program that will iterate…
A: numSet=[1,2,3];alphaSet=['A','B','C']; #using nested forfor i in range(0,len(numSet)):…
Q: t reads the data of the dates and stock volumes into two separate lists. Output: The program must…
A: First, create the input file "data.txt" and then use the code below:
Q: 6.23 LAB: Output numbers in reverse Write a program that reads a list of integers, and outputs those…
A: Required:
Q: students =[ [11, 12, 13], [21, 22, 23] ] avgs = [] # Write your code here: print('Average…
A: students =[[11, 12, 13],[21, 22, 23]]avgs = []# Write your code here:for value in students:…
Q: The code below prompts the user to enter their full name, and then converts the name to a list.…
A: I give the code as per your requirement along with output and code screenshot
Q: This following program is intended to print something sensible. .ORIG LEA R1, ? A ADD R1, R1, -2 B…
A: The OUT instruction prints something that is in R0 To print the string, the label should be I at ?…
Q: earrange Numbers in String Given a string, write a program to re-arrange all the numbers appearing…
A: NOTE: SINCE THE LANGUAGE OF THE PROGRAM IS NOT MENTIONED, I HAVE USED PYTHON FOR THE SOLUTION…
Q: Complete the following short program so that it creates a list of the characters in the variable…
A: Here we are looping over each character of the string. inside the loop, I have used the if-else…
Q: Complete the function below, which takes two arguments: data: a list of tweets search_words: a list…
A: The python code with the required function is given below. The snapshot of the code is attached with…
Q: Exercise 3: Write a program that reads from an input file “scores.txt” student test scores in the…
A: Objective: Need to write a program to read students' scores from a file and store the data to a…
Q: Three numbers a. Write a program that reads three numbers and prints “all the same” if they are all…
A: Note:- Since programming language is not mentioned we are providing solution in c++ . please repost…
Q: 4. Use a for loop to print a list containing your name, enrollment number, state, date of birth,…
A: 4. The current scenario here is to write the r programming code to print a list that containing the…
Q: Using a while loop and your is_prime function above, define a list containing the first 100 prime…
A: """ Program define a list containing the first 100 prime numbers using while loopand is_prime…
Q: I (Assign grades) Write a program that reads a list of scores and then assigns grades based on the…
A: class grade_calculator: def __init__(self): self.__marks_obtained = []…
Q: 15. Use sets to find the two six-digit numbers with all different digits where the square of the…
A: c=0for i in range(100000,1000000): s=set(list(map(int, str(i)))) if len(s)==6: m=i*i…
Q: Palindromes A palindrome is a string that is identical to itself when reversed. For example,…
A: As per above program we have to identify sting is palindrom or not no space and punctuation in…
Q: create a program that reads words from the user until the user enters a blank line. After the user…
A: Start declare list = [] //empty list while True follow steps 4 to 8 input word if word do if…
Step by step
Solved in 2 steps with 1 images
- By using while loop OR do..while loop, write a program that displays a list of groceries. Then, allow user to insert number of product that they want to buy, the item's code and quantity for each item. Finally, display the total price that the user needs to pay. Valid input for the number of product and quantity is positive number. Meanwhile valid number for items' code is only from 1 to 4. 1 Cooking oil 2 Curry powder RM 3.40 3 Detergent Potato chips RM 2.50 RM 8.50 4 RM 3.20 Sample output Emer number of product that you want to purchase (press 0 to exit) : 2 1.Enter item's code that you want to buy : 3 1.Enter the quantity of item that you want to buy: 1 2.Enter item's code that you want to buy : 0 2.Enter the quantity of item that you want to buy: 0 2.Enter item's code that you want to buy : 1 2.Enter the quantity of item that you want to buy; 2 Total price is RM 13.50# Lists A and B of integers are in the input, each on a separate line. # Task: Substitute all occurrences of maximum in B by minimum of value of A. #Print modified B. Print only values separated by single spaces. 111 Example: Input 3 23452345 2 3 4 5 55 20 33 11 55 33 11 33 44 44 55 OutputExercises: O. 1. write a program that will compute and display the sum of all whole numbers between 1 and 100 inclusive. (Solve using the do while... loop or do loop while). There is an interesting sequence of numbers called the Fibonacci Numbers. The set begins with 0 and 1. Then each succeeding number in the sequence is the sum of the previous two. Thus, the Fibonacci sequence is 0, 1, 1, 2, 3, 5, 8, 13, ... and so on. Write a program that will compute the first twenty numbers of this sequence and will display them.(Solve using the do until ... loop or do loop until) 3. Write a program that will allow the use display the numbers in increments or decrements of 2. Remember, the program must determine if the first number is less than or greater than the second number so that the display will occur. (Solve using the For-Next loop structure). to input two numbers. The program must then 2.
- a and b are int variables containing values, and a > b.Write a for loop that prints numbers from a to b (both inclusive) divisible by 7.(Example: if a=74, b=16, then it will print 70 63 56 .... 21)Write only the for loop with its block, nothing else.a and b are int variables containing values and a > b.Write a for loop that computes the sum of numbers from a to b (both inclusive) numbers with the last 2-digits 50.(Example: if a=700, b=128, then it will compute 650+550+450+....+150)Write only initialization of sum, and the for loop with its block, nothing else.Rearrange Numbers in String Given a string, write a program to re-arrange all the numbers appearing in the string in decreasing order. Note: There will not be any negative numbers or numbers with decimal part. Input The input will be a single line containing a string. Output The output should be a single line containing the modified string with all the numbers in string re-ordered in decreasing order. Explanation For example, if the given string is "I am 5 years and 11 months old", the numbers are 5, 11. Your code should print the sentence after re-ordering the numbers as "I am 11 years and 5 months old". sample input: I am 5 years and 11 months old sample output: I am 11 years and 5 months old Note: please solve this question along with hidden test case
- Archery Scorer. Write a program that draws an archery target (see Pro-gramming Exercise 2 from Chapter 4) and allows the user to click five times to represent arrows shot at the target. Using five-band scoring, abulls-eye (yellow) is worth 9 points and each successive ring is worth 2fewer points down to 1 for white. The program should output a score foreach click and keep track of a running sum for the entire series.French Articles: French country names are feminine when they end with the letter e, masculine otherwise, except for the following which are masculine even though they end with e: le Belize le Cambodge le Mexique le Mozambique le Zaïre le Zimbabwe Write a program that reads the French name of a country and adds the article: le for masculine or la for feminine, such as le Canada or la Belgique. However, if the country name starts with a vowel, use l’; for example, l’Afghanistan. For the following plural country names, use les: les Etats-Unis les Pays-Bascompare loans with various interest rates) Write a programthat lets the user enter the loan amount and loan period in number of years anddisplays the monthly and total payments for each interest rate starting from 5% to10%, with an increment of 1/4. Here is a sample run: Loan Amount: 10000Number of Years: 5Interest Rate Monthly Payment Total Payment5.000% 188.71 11322.745.250% 189.86 11391.595.500% 191.01 11460.70...9.750% 211.24 12674.5510.000% 212.47 12748.23
- n a while loop, generate a random integer from 0 to 9. Use srand() only once. Keep track of the number of iterations and quit the loop when the random integer is equal to 5. Report the number of iterations.1. Assume that you want to generate a table of multiples of any given number. Write a program that allows the user to enter the number and then generates the table, formatting it into 10 columns and 10 lines. Solve the problem with For loop. Name your program as Q1.cpp. Interaction with the program should look like this (only the first three lines are shown): (3 Marks) Enter a number: 7 7 14 21 28 35 42 49 56 63 70 77 84 91 98 105 112 119 126 133 140 147 154 161 168 175 182 189 196 203 210 2. Repeat Q1 using while loop. Name your program as Q2.cpp. (2 Marks) 3. Repeat Q1 using do while loop. Name your program as Q3.cpp. (2 Marks) 4.…Python Coding-While Loops (In PyCharm Community edition) Create a while loop that SUMS up ALL the numbers given from an initial number and an ending number. Example would be : Input1 : What is the first number? 0 Input2 : What is the last number? 3 DO NOT SHOW but these are the computations inside the code : 0 + 1 + 2 + 3 = 6 This is the Output : The sum of all the number from 0 to 3, is 6 In the code you are going to use a total variable and add each additional time it runs through the loop to that total. REMEMBER the assignment from the first unit of programming where we used this formula : BUT you are going to create your own method using a while loop to emulate what formula accomplishes WITHOUT using this formula. The user will put in the first number and the last to be SUMMED - you will use the while loop to calculate all of the additions leading to the final number.