Programming Assignment Create Pseudocode or a Flow Chart Hello, I would like to
ID: 3594069 • Letter: P
Question
Programming Assignment Create Pseudocode or a Flow Chart
Hello, I would like to see some ideas on a nice flow or pseudocode. Easy assignment but time consuming. Usually my flow charts aren't very creative. I would like to see how others would design a flow or write pseudocode. I have zero experienc writing pseudocode and only have done flow charts. It would be nice to see an example of pseudocode. Thank you! Here is the program itself...
# function to compare a and b
def compare(a,b):
# if a is greater than b , return 1
if a > b:
return 1
# if a and b are equal, return 0
elif a == b:
return 0
# if a less than b , return -1
elif a < b :
return -1
# testing
if __name__=="__main__":
# calling the compare function with a and b
print('compare(5,2) %d'%compare(5,2))
print('compare(2,5) %d'%compare(2,5))
print('compare(3,3) %d'%compare(3,3))
# getting values for a and b
a=int(input("Enter the value for a: "))
b=int(input("Enter the value for b: "))
print('compare(%d,%d) %d'%(a,b,compare(a,b)))
Explanation / Answer
I can say that Python code is close to a pseudocode. As you asked for a pseudocode here it is:
FUNCTION compare(a,b)
IF a > b THEN
RETURN 1
ELSE IF a == b THEN
RETURN 0
ELSE
RETURN -1
DECLARE INT a, b
READ a
READ b
result <- compare(a, b)
WRITE result
This is how the pseudocode looks for you code by following its standard notations.
**Comment for any further queries. Upvote if the answer is satisfactory.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.