Computer Science, asked by mirandacarolyn, 9 months ago

9.7 Code Practice: Question 3
Instructions
Use the following initializer list:

w = ["Algorithm", "Logic", "Filter", "Software", "Network", "Parameters", "Analyze", "Algorithm", "Functionality", "Viruses"]
Create a second array named s that stores the lengths of each word in the array above. Then, print—on separate lines—each word by printing the length of the word and then the word. Follow the same format as the sample run below.

Sample Run
9: Algorithm
5: Logic
6: Filter
8: Software
7: Network
10: Parameters
7: Analyze
9: Algorithm
13: Functionality
7: Viruses

Answers

Answered by poojan
13

Program: (INDENTATION is must!)

w = ["Algorithm", "Logic", "Filter", "Software", "Network", "Parameters", "Analyze", "Algorithm", "Functionality", "Viruses"]

s=[]

for word in w:

     l = len(word)

     s.append(l)

     print("{0}: {1}".format(l,word)))

Output:

9: Algorithm

5: Logic

6: Filter

8: Software

7: Network

10: Parameters

7: Analyze

9: Algorithm

13: Functionality

7: Viruses

Explanation:

Here, you are printing each element from the list and its length.

In addition, you are appending the length of each word into a list named 's' such that each word's length will be on the corresponding index in the list 's'

To get the list of lengths, once done with the loop, just print the list 's' with the statement print(s).

It gives the list of lengths as output.

Learn more:

1) Printing all the palindromes formed by a palindrome word.

brainly.in/question/19151384

2) Indentation is must in python. Know more about it at :

brainly.in/question/17731168

Similar questions