My school assignment requires me to convert this python code to mips, I am beginner at MIPS hence I have no idea how to approach this solution.
Please make sure to comment the code which could help me understand the code.
Any help would be appreciated.
TIA.
#Set Values
#take input for max no of symbols from user
max_no_of_symbols=int(input("Enter Max Number Of Sybols(should Be ODD)"))
#only enter odd num
if max_no_of_symbols %2 == 0:
print("Error, Please enter a odd number")
else:
#caculate num of spaces
NumOfSpaces=int((max_no_of_symbols-1)/2)
NumOfSymbols=1
while NumOfSymbols != max_no_of_symbols :
#print output
for i in range(NumOfSpaces):
print(" ",end="")
for i in range(NumOfSymbols):
print(NumOfSymbols, end="")
#adjusting values for new line
NumOfSpaces=NumOfSpaces-1
NumOfSymbols=NumOfSymbols+2
print(" ")
while NumOfSymbols != 0 :
#print output
for i in range(NumOfSpaces):
print(" ",end="")
for i in range(NumOfSymbols):
print(NumOfSymbols, end="")
#adjusting values for new line
NumOfSpaces=NumOfSpaces+1
NumOfSymbols=NumOfSymbols-2
print(" ")
Aucun commentaire:
Enregistrer un commentaire