Computer Science, asked by medikonduasa, 4 days ago

WAP to input and store 2o characters in a single dimensional away. display number of vowels, number special characters, number of digits, number of Alphabets, and number of characters equal to A​

Answers

Answered by Equestriadash
28

Co‎de: [in Python language]

\tt import\ numpy\ as\ np\\l\ =\ list()\\for\ i\ in\ range(6):\\{\ \ \ \ \ }c\ =\ inp ut("Enter\ a\ character:\ ")\\{\ \ \ \ \ }l.append(c)\\arr\ =\ np.array(l)\\print()\\print(arr,\ "is\ your\ given\ array.")\\print()\\vc\ =\ 0\\sc\ =\ 0\\dc\ =\ 0\\ac\ =\ 0\\na\ =\ 0

\tt for\ i\ in\ arr:\\{\ \ \ \ \ }if\ i\ in\ "AEIOUaeiou":\\{\ \ \ \ \ }{\ \ \ \ \ }vc\ =\ vc\ +\ 1

\tt for\ i\ in\ arr:\\{\ \ \ \ \ }if\ ord(i)\ >=\ 20\ and\ ord(i)\ <=\ 64\ and\ i.isdigit()\ ==\ False:\\{\ \ \ \ \ }{\ \ \ \ \ }sc\ =\ sc\ +\ 1

\tt for\ i\ in\ arr:\\{\ \ \ \ \ }if\ i.isdigit():\\{\ \ \ \ \ }{\ \ \ \ \ }dc\ =\ dc\ +\ 1

\tt for\ i\ in\ arr:\\{\ \ \ \ \ }if\ i.isalpha():\\{\ \ \ \ \ }{\ \ \ \ \ }ac\ =\ ac\ +\ 1

\tt for\ i\ in\ arr:\\{\ \ \ \ \ }if\ i\ ==\ 'A':\\{\ \ \ \ \ }{\ \ \ \ \ }na\ =\ na\ +\ 1

\tt print("Vowel\ count:\ ",\ vc)\\print("Special\ character\ count:\ ",\ sc)\\print("Digit\ character\ count:\ ",\ dc)\\print("Alphabet\ character\ count:\ ",\ ac)\\print("'A'\ character\ count:\ ",\ na)

Explanation:

We import the \tt numpy library to create the array later on. A list is created and a \tt for loop is initiated to retrieve the characters. As the characters are being entered, they're being added to the list earlier created. The array is made out of the list once the loop is complete. After that, we set suitable variables to store as the count record for the objective of the question. The required number of \tt for loops are initiated to check for various kinds of characters and to store the count of each type of character, as per the question. The final output is printed in appropriate \tt print() statements.

Similar questions