Question

nums = [8, 15, 6, 17, 33, 20, 14, 9, 12] Write Python code that: ...

nums = [8, 15, 6, 17, 33, 20, 14, 9, 12]

Write Python code that:

uses a function to print the size of the list named nums

uses a function to print the largest number in nums

prints the element 14 by using its index

makes a slice named subnums containing only 33, 20, and

0 0
Add a comment Improve this question Transcribed image text
Answer #1
nums = [8, 15, 6, 17, 33, 20, 14, 9, 12]
print(len(nums))
print(max(nums))
print(nums[6])
subnums = nums[4:7]
print(subnums)

Add a comment
Know the answer?
Add Answer to:
nums = [8, 15, 6, 17, 33, 20, 14, 9, 12] Write Python code that: ...
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
  • 1) Translate the following equation into a Python assignment statement 2) Write Python code that prints...

    1) Translate the following equation into a Python assignment statement 2) Write Python code that prints PLUS, MINUS, O ZERO, depending on the value stored in a variable named N. 3) What is printed by: 3 - 1 while 5: while 10 Print ) Page 1 of 9 4) Write a Python while loop that reads in integers until the user enters a negative number, then prints the sum of the numbers. 1-2 of 9 4) Write a Python while...

  • USING PYTHON PROGRAMMING LANGUAGE 15. Write code to open a file named data.txt, which contains 3...

    USING PYTHON PROGRAMMING LANGUAGE 15. Write code to open a file named data.txt, which contains 3 numbers, and print the sum of those numbers to the console 16. Write code that opens a file named words.txt containing an essay, and the prints out the SECOND word in the file to the console

  • Write a program that creates a list of 20 integers (between 1 and 40) using a...

    Write a program that creates a list of 20 integers (between 1 and 40) using a random number generator function. Write a function that returns the index (position) of the third largest element from the list of integers. If there are more than one third largest number, return the index of the first occurrence of that number. Eg: Assume that your main function has created the following list of integers generated from the random number function. [12, 30, 28, 4,...

  • Write a python code that takes in an number 0-9 and prints out the word of...

    Write a python code that takes in an number 0-9 and prints out the word of the number. For example 1 would print out one. Below is the skeleton of the code that needs to be filled in. def num2string(num): """ Takes as input a number, num, and returns the corresponding name as a string. Examples: num2string(0) returns "zero", num2string(1)returns "one" Assumes that input is an integer ranging from 0 to 9 """ numString = "" ################################### ### FILL IN...

  • Given the following 2D array double nums[MAXROW][MAXCOL] = {{ 7, 12, 8, 23, 43, 16, 9,...

    Given the following 2D array double nums[MAXROW][MAXCOL] = {{ 7, 12, 8, 23, 43, 16, 9, 15}, {21, 7, 14, 48, 13, 6, 43, 29), {11, 2, 17, 91, 36, 14, 65, 43), {18, 5, 47, 38,52, 1, 18, 26}}; int numRows = 4; int numCols = 8; Write a function called totalRow that has the array, the number of rows, and the number of columns passed in. It will then print the total of the row that has 11,...

  • Write a program that creates a list of 20 integers (between 1 and 40) using a random number generator function. Write a function that returns the index (position) of the third largest element from the...

    Write a program that creates a list of 20 integers (between 1 and 40) using a random number generator function. Write a function that returns the index (position) of the third largest element from the list of integers. If there are more than one third largest number, return the index of the first occurrence of that number. Eg: Assume that your main function has created the following list of integers generated from the random number function. [12, 30, 28, 4,...

  • Could someone please help me solve this in Python? Brief explanation of the code comments would...

    Could someone please help me solve this in Python? Brief explanation of the code comments would be greatly appreciated. indices_second_biggest: This function returns a list containing the indices of the second largest value in its sole argument, a nonempty matrix (list of lists), i.e. [row index, col index]. If the largest value occurs more than once, it counts as the second largest also. If there is only one element in the matrix, return [0, 0].

  • Write a Python program that tests the function main and the functions discussed in parts a...

    Write a Python program that tests the function main and the functions discussed in parts a through g. Create the following lists: inStock - 2D list (row size:10, column size:4) alpha - 1D list with 20 elements. beta - 1D list with 20 elements. gamma = [11, 13, 15, 17] delta = [3, 5, 2, 6, 10, 9, 7, 11, 1, 8] a. Write the definition of the function setZero that initializes any one-dimensional list to 0 (alpha and beta)....

  • This needs to be in python, however, I am having trouble with the code. Is there...

    This needs to be in python, however, I am having trouble with the code. Is there any way to use the code that I already have under the main method? If so, what would be the rest of the code to finish it? #Create main method def main(): #Create empty list list=[] #Display to screen print("Please enter a 3 x 4 array:") #Create loop for rows and have each entered number added to list for i in range(3): list.append([int(x) for...

  • Write a C++ function, lastLargestIndex that takes as parameters an int array and its size and...

    Write a C++ function, lastLargestIndex that takes as parameters an int array and its size and returns the index of the "last occurrence" of the largest element in the array. Include another function to print the array. Also, write a program to test your function. [HINTS) Create an array of size 15 in the main function and initialize it with the values shown in the below sample output. Pass the array and its size to function lastLargestindex; function lastLargestindex returns...

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