Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am using Python 3.5.2 4. Create a function called main. This function should c

ID: 3572932 • Letter: I

Question

I am using Python 3.5.2

4. Create a function called main. This function should create and initialize a list with the following strings: "hulk","spiderman","batman","superman","thor","ironman","captainamerica","ultron","falcon","wo lverine","rogue","bizzarro","lexluthor","kickass","cyclops","blade","obiwankenobi","lukeskywalker", "bladerunner","terminator","optimusprime","neo","link","mario","luigi" Make the main method call the filter_interesting function from exercise #3 above, and print each of the interesting super hero names from the list created earlier. Finally, print out the number of interesting super hero names. Invoke the main function.

Explanation / Answer

def is_interesting(a_string):
count = 0
for i in range(0, len(a_string)):
ch = a_string[i]
if ch == 'a' or ch =='i' or ch == 'e' or ch == 'o' or ch == 'u':
count = count + 1
if isPrime(count):
return True;
else:
return False;
  
def isPrime(n):
if n < 2:
return False;
for i in range(2, n/2):
if n % i == 0:
return False;
return True;
     
  
  
def filter_interesting(a_list):
list = []
for i in range(0,len(a_list)):
if is_interesting(a_list[i]):
list.append(a_list[i])
return list;
def main():
a_list_of_words = ["hulk","spiderman","batman","superman","thor","ironman","captainamerica","ultron","falcon","wo lverine","rogue","bizzarro","lexluthor","kickass","cyclops","blade","obiwankenobi","lukeskywalker", "bladerunner","terminator","optimusprime","neo","link","mario","luigi"]
print filter_interesting(a_list_of_words);
print "Number of Super heros: ", len(a_list_of_words)


main();

Output:

sh-4.3$ python main.py                                                                                                                                                                                                                                 

['spiderman', 'batman', 'superman', 'ironman', 'captainamerica', 'ultron', 'falcon', 'wo lverine', 'rogue', 'bizzarro', 'lexluthor', 'kickass', 'blade', 'lukeskywalker', 'bladerunner', 'terminator', 'optimusprime', 'neo', 'mario', 'luigi']        

Number of Super heros:  25

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote