DEV Community

Cover image for 47. Flowcharts and pseudocodes (Day 45)
Manoj Kumar
Manoj Kumar

Posted on • Originally published at emanoj.hashnode.dev

47. Flowcharts and pseudocodes (Day 45)

In today's coding class, we delved into two fundamental concepts that aid in structuring and simplifying code development: flowcharts and pseudocodes. While we also touched upon creating branches in Git repositories, I'll be focusing solely on exploring the power of flowcharts and pseudocodes here. The intricacies of Git repositories warrant dedicated attention and will be addressed in a separate post once I've grasped them thoroughly.

To grasp the utility of flowcharts and pseudocodes, let's dive into a practical example: determining the highest value among three numbers collected from a user.

Flowchart
Flowcharts, a staple in my daily 9-5 job, surprisingly translate seamlessly into the realm of coding. Their simplicity lies in their representationβ€”just visualize the task at hand and sketch it out in a flowchart. So, I can draw a flowchart like below for the example I highlighted before:

Flowchart

Pseudocode
Pseudocodes serve as the subsequent step, translating the visual flowchart into comprehensible language akin to our natural speech. These pseudocodes incorporate familiar basic commands, and in Python, they're delineated by #, which comments out the sentence, ensuring it's not processed. Subsequently, the actual coding commands are added based on the pseudocodes created. This is how it looks:

Take 3 numbers a,b and c as inputs from user
a = int(input("Enter number 1: "))
b = int(input("Enter number 2: "))
c = int(input("Enter number 3: "))

# Check the value of the numbers against each other for the highest num 
# if a > b
    # if a > c
        # display a
    # else
        # display c
if a > b:
    if a > c:
        print(a)
    else:
        print(c)

# else
    # if b > c
        # display b
            # else
                # display c

else:
    if b > c:
        print(b)
    else:
        print(c)

Enter fullscreen mode Exit fullscreen mode

When you run the above commands, you are asked for the numbers, and get the result at the end:

Enter number 1: 10
Enter number 2: 2
Enter number 3: 50
50

Awesome!

By utilizing flowcharts and pseudocodes, the daunting task of coding becomes more approachable. Breaking down tasks visually and translating them into human-readable instructions fosters a more methodical and comprehensive approach to problem-solving within the coding landscape. These methods act as guiding lights, illuminating the path toward efficient, structured, and logical coding practices.

Time: 11:30 PM. A warm Thursday night. Time to hit the sack!

Top comments (0)