Hack Forums
[Python] Python to Pseudo-Code - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Python to Pseudo-Code (/showthread.php?tid=5713952)



Python to Pseudo-Code - Obscurus - Sep 9, 2017

Hey,
I have made a simple game in Python (only 8 lines), however, I am struggling to convert it into Pseudo-Code. Can someone check this or write it correctly please?

Python Code
Spoiler (Click to View)

Pseudo-Code (Needs fixing?)
Spoiler (Click to View)


* - nOrr - Sep 9, 2017

Does pseudo code even have a specific syntax one needs to follow? I've always just written losely what my thoughts were, even if that meant mixing python/java/other-language together


* - Obscurus - Sep 9, 2017

(Sep 9, 2017 04:02 AM)nOrr Wrote:  Does pseudo code even have a specific syntax one needs to follow? I've always just written losely what my thoughts were, even if that meant mixing python/java/other-language together

yeah pseudo-code doesn't have a specific syntax, i just need my algorithm to be checked


* - vorticalbox - Sep 9, 2017

(Sep 9, 2017 04:05 AM)Obscurus Wrote:  yeah pseudo-code doesn't have a specific syntax, i just need my algorithm to be checked

I would be more worried about the code.

Code
x = "A1"  
while True:  
  z = str(input("Enter location from A1 to C3:"))  
  if z == x:  
    print("You found the treasure!")
  else:  
       print("You did not find the treasure! Try again!")  
    break

in is more for checking if something is in something not if sometimes equals something.

PHP Code

<?php 
my_string 
= 'This is my string'
print('my' in my_string)

my_list = ['1', '2', '3','4']
print(
5 in my_list) 



* - nOrr - Sep 9, 2017

(Sep 9, 2017 04:20 AM)vorticalbox Wrote:  I would be more worried about the code.
[...]
in is more for checking if something is in something not if sometimes equals something.

PHP Code

<?php 
my_string 
= 'This is my string'
print('my' in my_string)

my_list = ['1', '2', '3','4']
print(
5 in my_list) 

Why would you write 'abc' in 'abc'?


* - vorticalbox - Sep 9, 2017

(Sep 9, 2017 04:24 AM)nOrr Wrote:  Why would you write 'abc' in 'abc'?

I wouldn't, OP did for the check.


* - Obscurus - Sep 9, 2017

(Sep 9, 2017 04:20 AM)vorticalbox Wrote:  I would be more worried about the code.

Code
x = "A1"  
while True:  
  z = str(input("Enter location from A1 to C3:"))  
  if z == x:  
    print("You found the treasure!")
  else:  
       print("You did not find the treasure! Try again!")  
    break

in is more for checking if something is in something not if sometimes equals something.

PHP Code

<?php 
my_string 
= 'This is my string'
print('my' in my_string)

my_list = ['1', '2', '3','4']
print(
5 in my_list) 

Updated Code:

Code
x = "A1"    
while True:  
  z = str(input("Enter location from A1 to C3:"))  
  if z == x:    
    print("You found the treasure!")  
    break
  else:  
    print("You did not find the treasure! Try again!")

Better?