I have written the program using PYTHON PROGRAMMING LANGUAGE .
INPUT :
python .\sys.py 2,3,4,5,6,7 8 1
python .\sys.py 2,3,4,5,6,7 8 2
python .\sys.py 2,3,4,5,6,7 8 3
python .\sys.py 2,3,4,5,6,7 8 4
...
python .\sys.py 2,3,4,5,6,7 8 7
OUTPUT :
CODE :
import sys #Imported sys module
'''Taking the inputs from the command line
using sys module . Taking list of number , MultiplerM
and value of N.'''
Numbers = sys.argv[1].split(',')
MultiplerM = int(sys.argv[2])
ValueN = int(sys.argv[3])
#Converting list values from string to integer
for i in range(0,len(Numbers)):
Numbers[i] = int(Numbers[i])
#Multiplying the list values by the Multipler
#based on the Value N as mentioned in the quesion
if(ValueN > len(Numbers)):
pass #Pass which means it wont do nothing
else:
for j in range(ValueN-1,len(Numbers)):
if(j!=0):
#Multiplying the list values by multipler
Numbers[j] = Numbers[j]*MultiplerM
#Finally printing the list Numbers
print(Numbers)
Thanks ..
3.6.x10 every other We are passing in 3 inputs A list of numbers A multiplier value,...
Codio challenge We will pass you 2 inputs an list of numbers a number, N, to look for Your job is to loop through the list and find the number specified in the second input. Output the list element index where you find the number. If N is not found in the list, output -1. Tip: Remember the break statement? It exits the loop. You can (but don’t have to) use this. # Get our input from the command line...
3.5 max number We will pass in a list of numbers your job is to find the largest number in that list and outputted it’s index , not the actual value # Get our numbers from the command line import sys 4 numbers sys.argv[1].split',') Collagse) Challenges 5 numbers int(i) for i in numbers] 3. 5. Max number # Your code goes here We will pass in a list of numbers. Your job is to find the largest number in that...
The program defined in insertionSort.cpp gets a list of numbers as input from the user and calls the insertion sort algorithm to sort them. It also displays the list before and after the sorting. The insertion sort algorithm should be defined in the InsertionSort.h file, but this definition has been omitted and it is your task to provide it. The appropriate insertion sort function is to be defined in the InsertionSort.h file. The InsertionSort.h file performs an include of Swap.h,...
Develop a Generic String List (GSL). NOTE: I have done this lab but someting is wrong here is what i was told that was needed. Ill provide my code at the very end. Here is what is missing : Here is my code: public class GSL { private String arr[]; private int size; public GSL() { arr = new String[10]; size = 0; } public int size() { return size; } public void add(String value) { ...
Create a function l_mode that finds the index of the value that occurs most often in an array. The input to your function is an array of integers A and the number of elements in the array 0 < n <= 10^3. Assuming v is the most frequent element in the array, your function will return the index i of the first (leftmost) occurrence of v in A. You can assume that -500 <= A[i] <= 500, for 0 <=...
Q1: You can find a file that defines the CircularlyLinked List class similar to what we discussed in the class. Download the file and work on it. Your task is to: 1. Complete the missing methods in the file as discussed in the class. Search for the comment/" MISSING / in the file to see the methods that need to be completed. 2. Add the following methods to the class a. public Node getMin 1. Task: find the node with...
iii.print out the arraylist iv.reverse all the elements v.print out this arraylist vi.make a clone of the arraylist vii.remove all the elements at any odd index of the original arraylist (not the cloned one) viii.print out the original arraylist ix.reverse the cloned arraylist x.print out the cloned arraylist (this arraylist should still contain the original sequence of elements in order) xi.merge the cloned arraylist to the original arraylist (please think about what happens and draw a diagram for yourself to...
In class we wrote a method closestPairFast that on an input array of numbers, finds the distance of the closest pair by first sorting the input array and then finding the closest adjacent pair. (See the file ClosestPair1D.java in the Code folder on D2L.) In this problem, you are asked to modify the method so that it returns an integer array consisting of the indices of the closest pair in the original array. If there is a tie, just return...
JAVA PROGRAMMING PLEASE This lab has three parts: Create an ArrayList class. Create a LinkedList class. Print out the results after testing each of the methods in both of the classes and solving a simple problem with them. Task 1 – ArrayList Class Create an ArrayList class. This is a class that uses an internal array, but manipulates the array so that the array can be dynamically changed. This class should contain a default and overloaded constructor, where the default...
In this project, you are asked to design and implement a class for double link list to hold integers: – The class should be called DList, you also need a class called Node that contains an int as the data – Node needs the following data: int data; //the data held by the node Node* parent; //the parent of the Node Node* child; //the child of the Node – Node needs the following public functions: Node(int)// constructor to create a...