Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #We provide you with a number N.
- #Create a list then, using a loop, populate the list with N elements. Set each list element to the index multiplied by 10.
- #Beware: we might pass in a value 0, in which case you should return an empty list.
- # Get N from the command line
- import sys
- N= int(sys.argv[1])
- # Your code goes here
- #create a list
- my_list = []
- my_newlist =[]
- if N <= 0:
- print(my_list)
- else:
- for x in range(N):
- my_list.append(x)
- my_newlist= [i* 10 for i in my_list] # not getting the statement 'i * 10 for in i' statement
- print(my_newlist)
- ##############
- 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
- import sys
- M= int(sys.argv[2])
- N= int(sys.argv[3])
- # convert strings to integers
- numbers= sys.argv[1].split(',')
- for i in range(0, len(numbers)):
- numbers[i]= int(numbers[i])
- numbers[N-1::N] = [x * M for x in numbers[N-1::N]] # I have no clue what kind of wizardry this is. but it looks nice and it works
- print(numbers)
- #################
- # Get our list from the command line arguments
- import sys
- numbers= sys.argv[1:]
- # Convert the command line arguments into 2d list
- for i in range(0,len(numbers)):
- numbers[i]= numbers[i].split(',')
- total=0
- for row in numbers:
- subTotal = sum([int(col) for col in row]) #I don't get the brackets, and again for numbers for numbers in row - doesn't make sense # to me
- print(subTotal)
- total += subTotal
- print(total)
- ''' The below are all failures - one of the only I kept
- total=0
- tTotal=0
- for row in range (len(numbers)):
- for col in range(len(numbers[0])):
- total += int(numbers[row][col])
- tTotal += total
- print(total)
- print(tTotal)
- # Get our list from the command line arguments
- import sys
- numbers= sys.argv[1:]
- # Convert the command line arguments into 2d list
- for i in range(0,len(numbers)):
- numbers[i]= numbers[i].split(',')
- total=0
- for row in numbers:
- subTotal = sum([int(col) for col in row])
- print(subTotal)
- total += subTotal
- print(total)
- total=0
- tTotal=0
- for row in range (len(numbers)):
- for col in range(len(numbers[0])):
- total += int(numbers[row][col])
- tTotal += total
- print(total)
- print(tTotal)
- '''
- #########################
- # Get our arguments from the command line
- import sys
- A= int(sys.argv[1])
- B= int(sys.argv[2])
- # Your code goes here
- #Create a row of columns
- newList=[]
- for x in range(0, A): # this says this many times in variable A do
- newList.append([]) # appends a new list x amount of times
- for y in range(0, B): # this says as many times in B
- newList[x].append('R' + str(x) + 'C' + str(y)) #
- print(newList) #this only prints once because it's not indented
- # So for the input of 2,3 it creates two lists and then while in the
- # for y statement it says n
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement