Question
3.6.x10 every other

We are passing in 3 inputs

A list of numbers
A multiplier value, M
A value, N
You should multiply every Nth element ( do not multiply the 0th element)by M. So if N is 3 you start with the 3rd element which is index 2

If there are less than N elements then you should output the unchanged input list
Get our input from the command line port sys İnt(sys.argv [2] ) int (sys.argv[3]) Collape) Challengs 3. 6. X 10 every other convert strings to integers umbers sys.argv[1].split, for i in range(e, len (numbers)): We are passing in 3 inputs .a list of numbers . a multiplier value, M . a value,N numbers[i]- int(numbersi]) Your code goes here You should multiply every Nth element (do not multiply the 0th element) by M. So, if N is 3 you start with the 3rd element, which is index 2. If there are less than N elements then you should output the unchanged input list Activate Windows 342 PM Python 1:0) O Type here to search MacBo
0 0
Add a comment Improve this question Transcribed image text
Answer #1

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 :

Now Text D DL.txt New I ext Documentbxt nesyspy3 Select Windows PowerShell new 1 import sys tImported sys module 3 부, Taking the inputs from the command line 5 Land value of N. PS C:\Users\ponkumar.ORADEV Desktop> python sys.py 2,3,4,5,6,7 81 [2, 24, 32, 40, 48, 56] Ps C:\Usersiponkumar.ORADEV1Desktop> python sys.py 2,3,4,5,6,7 8 2 [2, 24, 32, 40, 48, 56] Ps C:\Users ponkumar.ORADEV Desktop> python sys.py 2,3,4,5,6,7 8 3 [2, 3, 32, 40, 48, 56] Ps C:\Users ponkumar.ORADEV Desktop> python sys.py 2,3,4,5,6,7 8 4 [2, 3, 4, 40, 48, 56] PS C:Users\ponkumar.ORADEV\Desktop> python sys.py 2,3,4,5,6,7 8 5 [2, 3, 4, 5, 48, 56] s C:\Users\ponkumar.ORADEV Desktop> python sys.py 2,3,4,5,6,7 H 6 [2, 3, 4, 5, 6, 56] Ps C:\Users ponkumar.ORADEVDesktop> pythonsys.py 2,3,4,5,6,7 8 7 b, 3, 4, 5, 6, 7] Ps C:\Users\ponkumar.ORADEV Desktop> 4 using sys module Taking list of number MultiplerM Numbers = sys , argv [ 1 ] . split ( ) MultiplerM-int (sys.argv [2]) 8 ValueNint (sys.argv3]) 10 #Converting list values from string to integer 1 for i in range (,len (Numbers)) 12 Numbers[i] int (Numbers [i]) 14 #Multiplying the list values by the Multipler 15 based on the Value N as mentioned in the guesion 16 日if (ValueN > len (Numbers)) : 17 1 B 19 20 21 ど2 23 24 #Finally printing the list Numbers 25 pass #Pass which means it wont do nothing else for j in range (ValueN-1,len (Numbers)) #Multiplying the list values by multipler Numbers[j] Numbers j)*MultiplerM print (Numbers)

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 ..

Add a comment
Know the answer?
Add Answer to:
3.6.x10 every other We are passing in 3 inputs A list of numbers A multiplier value,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Codio challenge We will pass you 2 inputs an list of numbers a number, N, to...

    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...

    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...

    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...

    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...

    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...

    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...

    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...

    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....

    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...

    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...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT