#๐Ÿ”’ trace table

22 messages ยท Page 1 of 1 (latest)

pearl tree
#

I learn python at school and I know this is written in pseudocode but I'm so lost as to where to start to fill out the trace table cause everything I do is wrong.

flint nebulaBOT
#

@pearl tree

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

plush mason
#

I have no idea about what a trace table is - but would writing/running the code in Python help you get there?

#

You can more or less translate this code to Python line for line, replacing each line with the Python syntax, and it will work in Python. It won't be terribly Pythonic (this pseudocode is actually harder to understand than Pythonic code would be) but it would workd

pearl tree
#

Okay I'll try that thank you

split vortex
#

Is this essentially like a 'how to python for a X developer' or something? Like where x is c++ or javascript or..?

#

Or has your teacher just printed this out and said "do this in python"

pearl tree
#

Yeah it's like the trace table there it's just I don't know where to start on the trace table

#

I've put the code in python and still not had any luck

#

I've put the code in python and still not had any luck

split vortex
#

Has your teacher asked you to do this in python? or another language?

pearl tree
#

I need to fill out the trace table so it doesn't matter what language

split vortex
#

Fair enough, I'm asking because I was wondering about the relevance to python since this is not python syntax.

Start with the while loop

#

I'm going to assume it's not written in lua (most programming languages are 0 indexed based)

pearl tree
#

Okay

#

Thank you

split vortex
#
# fun fact: this would only work for a 0 index programming language. 
array = (10, 3, 7, 11, 19)
newArray = ()
rev = len(array) - 1
index = 0
iTot = 0

# Hint: Algorithm starts here
while array[index] == array[rev]:
    newArray.append(array[index] * array[rev])
    index += 1
    iTot += 1

nTot = 1

for i in newArray:
    nTot *= i

fTot = iTot + nTot
# and ends here
#

This is how to represent it in python code. Hopefully that helps you solve it.

pearl tree
#

Thank you so much

flint nebulaBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.