Write a python program able to. A : Display a string that consists of the first
ID: 3801994 • Letter: W
Question
Write a python program able to.
A: Display a string that consists of the first letter and last letter from each of the names in the list a
As an example the display should look like “EdAsNn etc. use the + operator and prior lab
B: Display list a with all the names reversed That is display
“dilcuE”, sedemihcrA” etc.
C: Display the number of vowels in list a NOTE ignore case ‘A’ and ‘a’ are to be considered the same. See OUTPUT below for the vowel ‘I’ (There are eight I’s in the list a SEE BELOW
Vowels are [‘a’, ‘e’, ‘i’, ‘o’, ‘u’] NOTE: ‘A’ and ‘a’ are considered the same
D: Display the total number of characters in the list a Hint: Sum the lengths of each name
LIST
a = [ "Euclid", "Archimedes", "Newton","Descartes", "Fermat",
"Turing", "Euler", "Einstein", "Boole", "Fibonacci",
"Nash", "Wiles", "Cantor", "Gauss", "Plato"]
I'd appreciate if i can get the code :D
Explanation / Answer
A: program to display first and last letter of all the strings of given array,
li=["Euclid", "Archimedes", "Newton","Descartes", "Fermat",
"Turing", "Euler", "Einstein", "Boole", "Fibonacci",
"Nash", "Wiles", "Cantor", "Gauss", "Plato"]
for i in range(len(li)):
print(li[i]);
print(li[i][0]+li[i][-1]);
B: program to display reverse of all the strings of given array,
li=["Euclid", "Archimedes", "Newton","Descartes", "Fermat",
"Turing", "Euler", "Einstein", "Boole", "Fibonacci",
"Nash", "Wiles", "Cantor", "Gauss", "Plato"]
for i in range(len(li)):
a=li[i];
print(a)
print(a[::-1]);
C: program to display number of vowels of given array,
li=["Euclid", "Archimedes", "Newton","Descartes", "Fermat",
"Turing", "Euler", "Einstein", "Boole", "Fibonacci",
"Nash", "Wiles", "Cantor", "Gauss", "Plato"]
count=0
for i in range(len(li) ) :
vowel=("aeiouAEIOU")
string=li[i]
for i in string:
if i in vowel:
count +=1
print(count);
D: program to display total number of characters of all the strings of given array,
li=["Euclid", "Archimedes", "Newton","Descartes", "Fermat",
"Turing", "Euler", "Einstein", "Boole", "Fibonacci",
"Nash", "Wiles", "Cantor", "Gauss", "Plato"]
a=0
for i in range(len(li) ) :
a=a+len(li[i]);
print(a);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.