Question

in python For a list of 100 items, the index of the last item is: (please...

in python
For a list of 100 items, the index of the last item is:
(please don't use negative indexing here...)
Answer:

Homework Answers

Answer #1
import random
random_no = random.sample(range(100), 100).   #created the 100 elements list
random_no                                     #printing the elements
random_no[len(random_no)-1]                   #accessed the last elements

I used random.sample to create a 100 elements list to show you how to retrieve the last element.

And accessed the last element using len() function minus 1. (because the indexing starts from 0).

I think this answered your question. If you still got any query. Do post in the comments.

Know the answer?
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
Similar Questions
1.Implement a function which will -       + Accept a number, num, and a list, my_list...
1.Implement a function which will -       + Accept a number, num, and a list, my_list as arguments       + return True if num exists in my_list       + return False otherwise 2. Write Python code to implement the following function - def find_in_list(item, my_list):     """     Look for an item from my_list (of items.)     If the item is found, return the index position of the item;     otherwise, return -1.     """       #add your code here...
The last thing we will learn about in python is functions. Functions are a great way...
The last thing we will learn about in python is functions. Functions are a great way to organize your program - we use them to write code that is executed only under certain circumstances - for instance when you're using Amazon, any of the following are likely functions within their program: - Add item to cart, determine arrival date,  create a new address, compute taxes, compute shipping charges, charge credit card Because you can write a task-specific function once, and ensure...
Below is a list of items. indicate the item number and the line and section of...
Below is a list of items. indicate the item number and the line and section of the Balance Sheet that the item should be reported. (Example: assume there was an Item 8. Postage Stamps, the correct answer would be 8. Prepaid Expenses, Current Asset) Item 1. Compensating balances held for short-term borrowing arrangements Item 2. Savings account Item 3. Cash set aside as a bond sinking fund for bonds maturing in 3 years Item 4. Treasury bills with original maturing...
Name the script for.sh.  This script will create a shopping list. Ask the user to enter items...
Name the script for.sh.  This script will create a shopping list. Ask the user to enter items separated by a space. Read the list. Use a for loop to write (use echo) the items to a file called shopping_list. You should use >> to append the output to the file, so each time the script is run the list should get longer. After the for loop finishes, display (use cat) the contents of the shopping list with 1 item per line....
(((Python))) How can we use a LIST in a sequence or an IF Statement? Do we...
(((Python))) How can we use a LIST in a sequence or an IF Statement? Do we create a list, like in a Tuple, or can we ask a user for a set of items to add into our list? Give some examples if you can.
Please create a function with python to read a mixed numeric/alphabetic (strings) list and then outputs...
Please create a function with python to read a mixed numeric/alphabetic (strings) list and then outputs the following: The sum of the numeric values in the list A count of the non-numeric values in the list
Obesity trends have been increasing rapidly over the last several decades. Please List some of the...
Obesity trends have been increasing rapidly over the last several decades. Please List some of the health issues that obesity increases the risk for developing. While BMI is associated with fat, explain why can't we just use BMI to assess an individual's fat. Describe (don't just list) how we assess a healthful weight.
Show the Python statement that creates a list called aList and initializes its values to 7,...
Show the Python statement that creates a list called aList and initializes its values to 7, 3, 5, 2, 8, 6. Show the Python statement that would output the first 2 values of aList. You must use the slice operator (the colon). Show the Python statement that would output the last 3 values in aList. You must use the slice operator.
8.19 LAB: Grocery shopping list (linked list: inserting at the end of a list) PLEASE ANSWER...
8.19 LAB: Grocery shopping list (linked list: inserting at the end of a list) PLEASE ANSWER IN C++ Given main(), define an InsertAtEnd() member function in the ItemNode class that adds an element to the end of a linked list. DO NOT print the dummy head node. Ex. if the input is: 4 Kale Lettuce Carrots Peanuts where 4 is the number of items to be inserted; Kale, Lettuce, Carrots, Peanuts are the names of the items to be added...
When we delete an existing item from an unsorted linked list and insert a new item...
When we delete an existing item from an unsorted linked list and insert a new item into a sorted linked list, we use temporary pointers to hold addresses of nodes. Please explain how many pointers we need and why. You could use a chart/diagram to show the difference.