Question
(+25) Using the list defined as a below, write a Python program that will Display the longest name (done #12 below ) Display the shortest
(+25) Using the list defined as a below, write a Python program that will
Display the longest name (done #12 below ) Display the shortest name Display the number of names in the list NOTE: your answer should be 11 but do NOT use the constant 11 in your output; code the size of the list Display a string that consists of the first letter from each of 11 names in the list a
See 9 in the output and consider using the + operator Must use a loop
Display a string that consists of the last letter from each of 11 names in the list a
See 10 in the output Must use a loop
Ask the user for a letter. Display the number of times the letter appears in the list See the count function from the prior labs Sort list a and display the list i.e. the first name in the list should be Archimedes; last name is Turing Sort the list in reverse order and display the list i.e. the first name should be Turing and the last Archimedes Display the number of vowels Vowels are { A, a, E, e, I, I, O, o, U, u }
Python code template to consider:Please see the Source code tab for the code below (Lab07Template.py)
a = [ "Euclid", "Archimedes", "Newton","Descartes", "Fermat", "Turing", "Euler", "Einstein", "Boole", "Fibonacci", "Nash"] print ('1', a) print ('2', a[2]) print ('3', a[len(a)-1]) print ('4', a[2][0]) print ('5', a[2][1]) s = a[2] + a[3] print('6', s) print('7',len(a)) print('8',a[0], " ", len(a[0])) print('9',a[0][0] + a[1][0]) x = len(a[0]) - 1 y = len(a[1]) - 1 print('10', a[0][x]+ a[1][y]) j = 0 for k in a: print('11..', k, len(k), k[j]) maxlen =0 for k in a: if len(a[j])> maxlen: maxlen = len(a[j]) t = a[j] j = j+1 print('12', t, "max length is ", len(t) ) OUTPUT
1 ['Euclid', 'Archimedes', 'Newton', 'Descartes', 'Fermat', 'Turing', 'Euler', 'Einstein', 'Boole', 'Fibonacci', 'Nash']
2 Newton
3 Nash
4 N
5 e
6 NewtonDescartes
7 11
8 Euclid 6
9 EA
10 ds
11.. Euclid 6 E
11.. Archimedes 10 A
11.. Newton 6 N
11.. Descartes 9 D
11.. Fermat 6 F
11.. Turing 6 T
11.. Euler 5 E
11.. Einstein 8 E
11.. Boole 5 B
11.. Fibonacci 9 F
11.. Nash 4 N
12 Archimedes max length is 10
NOTE:
Please submit your solution as it as LastNameLab07.py with your answers to the lab
You will submit two files
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started