# Entry checker

Page 1 of 1

## 1 Replies - 251 Views - Last Post: 13 November 2019 - 02:42 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=417801&amp;s=aa32784c2f3b03181df4e48e5998d8f7&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 kam536

Reputation: 0
• Posts: 52
• Joined: 21-March 18

# Entry checker

Posted 12 November 2019 - 08:22 PM

```import numpy as np

print("Hello,\n")
print("Welcome to the Python Matrix Application")

print("Do you want to play the Matrix Game?: ")
entry=input("Enter Y for Yes or N for No")
if entry =="Y":
elif entry =="N":
print("Thank-you for trying the Python Matrix Game!")
break
else:
print("Invalid entry please restart and try again")

def checkEntry(inputValue):
try:
float(inputValue)
except ValueError:
return False
return True

def enterMatrixs():
matrix = np.zero((3,3))
for row in range(3):
for column in range(3):
check=False
while not check:
entry=input('Enter element at position ({:D/>/>},{:D/>/>}):'\
.format(row + 1, column + 1)
check= checkEntry(entry)
if not check:
print('Please enter a numeric value!')
mat[row, column] = float(num)
print()
return matrix

return matrix

matrix1=enterMatrixs()
print(matrix1)

matrix2=enterMatrixs()
print(matrix2)

print("Select a Matrix Operation form the list below:")
print("b.Subtraction")
print("c.Matrix Multiplication")
print("d.Element by Element Multiplication")

selection= input("What is your Selection?: ")

while True:
if selection == 1:
print("You selected Addition. The results are: ")
add = matrix1 + matrix2
print("The Transpose of the results are: ")
print("The row and column mean values of the results are: ")

if selection == 2:
print("You selected Subtraction. The results are: ")
sub = matrix1 - matrix2
print(sub)
print("The Transpose of the results are: ")
print(sub.T)
print("The row and column mean values of the results are: ")
print("Rows: ",np.mean(sub,1))

if selection == 3:
print("You selected Matrix Multiplication. The results are: ")
mul = np.matmul(matrix1,matrix2)
print(mul)
print("The Transpose of the results are: ")
print(mul.T)
print("The row and column mean values of the results are: ")
print("Rows: ",np.mean(mul,1))
print("Columns: ",np.mean(mul,0))

if selection == 4:
print("You selected Element by Element Multiplication.The results are:")
emul = np.multiply(matrix1,matrix2)
print(emul)
print("The Transpose of the results are: ")
print(emul.T)
print("The row and column mean values of the results are: ")
print("Rows: ", np.mean(emul,1))
print("Columns: ", np.mean(emul,0))

else:
print("Invaild Entry. Restart and try again!")

```

This is the error I am receiving:
File "/home/ec2-user/environment/Project4/Python Matrix Math Application Code.py", line 38
check = checkEntry(entry)
^
SyntaxError: invalid syntax

How would I make the checkEntry to work correctly?

Is This A Good Question/Topic? 0

## Replies To: Entry checker

### #2 ndc85430

• I think you'll find it's "Dr"

Reputation: 981
• Posts: 3,870
• Joined: 13-June 14

## Re: Entry checker

Posted 13 November 2019 - 02:42 AM

Are you missing the closing paren for input on line 31?

Also, the plural of "matrix" is "matrices".

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }