Computer Science, asked by manbikpattnaik10, 5 days ago

WAP to store 25 numbers in a Single dimension array then display numbers in one column and even or odd Message in another column with appropriate heading as follows:
Number Message
10 Even
12 Even
101 Odd​

Answers

Answered by YOSHINCHAN
6

Answer:

in the attachment

PLEASE MARK IT AS BRAINLIEST

Attachments:
Answered by Equestriadash
19

C‎ode: [in Python language]

\tt import\ pandas\ as\ pd\\import\ numpy\ as\ np\\l\ =\ list()

\tt l\ =\ list()\\for\ i\ in\ range(25):\\{\ \ \ \ \ }n\ =\ int(inp ut("Enter\ a\ number:\ "))\\{\ \ \ \ \ }l.append(n)

\tt arr\ =\ np.array(l)\\d\ =\ dict()\\for\ i\ in\ arr:\\{\ \ \ \ \ }if\ i\%2\ ==\ 0:\\{\ \ \ \ \ }{\ \ \ \ \ }d[i]\ =\ "Even"\\{\ \ \ \ \ }else:\\{\ \ \ \ \ }{\ \ \ \ \ }d[i]\ =\ "Odd"

\tt df\ =\ pd.DataFrame(\{"Number":list(d.keys()),\ "Message":list(d.values())\})\\print(df.to\_string(index\ =\ False))

Explanation:

To create an array, we require the \tt numpy package. It is imported, along with the \tt pandas package which will be required later on. We then create a list, to store the numbers that are going to be entered by the user through a \tt for loop. As the numbers are being entered, they're being added to the list using the \tt append() method. Once that's done, we create an array out of the list obtained, as per the question. After that, we create a dictionary to store the kind, i.e., whether odd/even into it with the numbers as the keys, also through a

Similar questions