i. Create a list – List_1 with 6 numbers (of your choice)
ii. Create another list – List_2 with another 6 numbers (of your choice)
iii. Display appropriate headings
iv. Use a loop to multiply the numbers and display them
In python
Answers
Answer:
To calculate the highest number which can divide all these three numbers, we will have to find their HCF.
the factors of 111 are 3 and 37
of 185 are -- 5 and 37
and of 296 are -- 2,2,2 and 37
so, the hcf is 37.
therefore, maximum 37 animals can be taken in
the boat at a time. total no. of animals = 111+185+296 = 592 so, no. of trips = 592 divided by 37 = 16
Explanation:
You can just use a list comprehension:
my_list = [1, 2, 3, 4, 5]
my_new_list = [i * 5 for i in my_list]
>>> print(my_new_list)
[5, 10, 15, 20, 25]
Note that a list comprehension is generally a more efficient way to do a for loop:
my_new_list = []
for i in my_list:
my_new_list.append(i * 5)
>>> print(my_new_list)
[5, 10, 15, 20, 25]
As an alternative, here is a solution using the popular Pandas package:
import pandas as pd
s = pd.Series(my_list)
>>> s * 5
0 5
1 10
2 15
3 20
4 25
dtype: int64
Or, if you just want the list:
>>> (s * 5).tolist()
[5, 10, 15, 20, 25]