Jump to content

Help With Making a FlowChart or Pseudocode

Hafiz75

I need help with turning Python Code to either A FlowChart or pseudocode. I think I have done the pseudocode but i'm not sure if it right. 

Here is the Python Program:

 userinput= input("Whats your File Called? \n" )
            concat=userinput+".txt"
            def main():
                f=open(concat, "r")
                if f.mode == 'r':
                   contents = f.read()
                   print(contents)
            if __name__== "__main__":
                
              main()
            

 

Here is the Attempted Pseudocode:

userinput= input("Whats your File Called? \n" )
            concat=userinput+".txt"
            FUNCTION main():
                f=open(concat, "r")
                IF f.mode = 'r':
                   contents <- f.read()
                   OUTPUT contents
                ENDIF
            ENDFUNCTION

            IF __name__== "__main__":
              main()
            ENDIF

CPU: Ryzen 5 2600X | Motherboard: MSI B450M Mortar (Black) RAM: Corsair Vengeance LPX 16GB (2x 8GB) 3000MHz DDR4 | GPU: MSI Radeon RX 580 ARMOR 8GB | Storage: Samsung 860 QVO 1TB and Samsung 970 EVO 250GB | PSU: Corsair CX650M 650W Case: Cooler Master MasterBox Q300L | Monitor: ASUS VZ279HE | Mouse: Logitech M171 Wireless | Keyboard: Cherry DC 2000 | Mousepad: None | Speakers: Logitech Z333

Link to comment
Share on other sites

Link to post
Share on other sites

pseudo code is more like

 

ask user for input file name

store input file name into variable called "userinput"

append ".txt" to the userinput contents

open file name with the name specified in the userinput variable

if there are no errors and file mode is correct (read mode)

 read contents of file and store it a variable

 print variable contents to screen

end if

close file

 

something like that.

 

Link to comment
Share on other sites

Link to post
Share on other sites

Pseudocode is hardly a defined thing, its mainly just supposed to be a version of your code written in plain English.

I would not include stuff like `IF __name__ == "__main__"` since its not exactly needed for pseudocode.

 

I'd honestly go even simpler than you have:

 

Prompt for file name, then add "txt" to end.
Open the given file.
If the file is readable
    Get its contents and print them.

 

That said, pseudocode is more what you find useful than a defined specification. If I'm writing some pseudocode to lay out some code, I broadly go for the style I used above, or maybe a very loose python syntax where the more complicated things are simplified to English. So in that style, maybe I'd do something like:

 

input("Input file name") + ".txt"
open(givenFile)
if openedFile == readable:
	print(openedFile.lines())

 

Broadly in the more "code" style pseudocode, I try to only use the very basics: input, print, while/for and if statements. The rest I'll do in English.

 

Do some and just find what makes the most sense to you. I find it useful for complicated bits of code to stub out what I'm going to add in pseudocode as comments, so that I can go in under each line of pseudocode and add the real stuff. Doing that gets you better at finding the style you like.

CPU: 6700k GPU: Zotac RTX 2070 S RAM: 16GB 3200MHz  SSD: 2x1TB M.2  Case: DAN Case A4

Link to comment
Share on other sites

Link to post
Share on other sites

  • 5 months later...

I know it's late and this is a big request, but can anyone help me with designing a flowchart? It would be much appreciated!

 

#5 is the assignment in question.

IMG_1079.jpg

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×