Skip to content

Instantly share code, notes, and snippets.

@TristenHarr
Created January 20, 2017 22:08
Show Gist options
  • Select an option

  • Save TristenHarr/756dd0016ff08149ea12bd5c9735f510 to your computer and use it in GitHub Desktop.

Select an option

Save TristenHarr/756dd0016ff08149ea12bd5c9735f510 to your computer and use it in GitHub Desktop.
def Input():
var = '/'+'Input <>'+'/'+';\n'
return var
def Output():
var = '/'+'Output <>'+'/'+';\n'
return var
def If():
first = 'if (<>)'+'\n{\n<>'
return first
def IsTrue():
maybe = input('Is this the last value that is True? Y/N ').strip().lower()
if maybe == 'y':
return '}\n{\n<>'
else:
return ';\n'
def IsFalse():
maybe = input('Is this the last value that is False? Y/N ').strip().lower()
if maybe == 'y':
return '}\n'
else:
return '<>;\n'
def While():
return 'while (<>)\n{'
def WhileTrue():
maybe = input('Is this the last value that is in the loop? Y/N ').strip().lower()
if maybe == 'y':
return '}\n{'
else:
return '<>;\n'
def Statement():
return ';'
def WhileFalse():
maybe = input('Is this the last value that is in the loop? Y/N ').strip().lower()
if maybe == 'y':
return '};\n'
else:
return '<>;\n'
def Declaration():
return '<>;\n'
def my_loops():
go = True
my_list = []
my_values = ['Input','While','InsideWhile','OutsideWhile', 'If', 'InsideIf', 'OutsideIf', 'Output','Declaration','End']
my_statement = 'Start;\n'
while go:
print('''You're code so far: '''+('{} '*len(my_list)).format(*my_list))
first = int(input('''
1. Input
2. While
3. Inside While
4. Outside While
5. If
6. Inside If
7. Outside If
8. Output
9. Declaration
10. End
'''))
if first == 1:
my_statement += Input()
elif first == 2:
my_statement += While()
elif first == 3:
my_statement += WhileTrue()
elif first == 4:
my_statement += WhileFalse()
elif first == 5:
my_statement += If()
elif first == 6:
my_statement += IsTrue()
elif first == 7:
my_statement += IsFalse()
elif first == 8:
my_statement += Output()
elif first == 9:
my_statement += Declaration()
elif first == 10:
my_statement += 'End'
print(my_statement)
break
my_list.append(my_values[first-1])
my_loops()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment