Today was an exciting one. Learned some control flow stuff which has me thinking about the possibilities of making an interactive story with Python…
I learned:
Python, different than other programs, just uses indented blocks of code to signify some relations (apparently other codes use actual {} or other syntax stuff?). Also, whenever a line ends in “:” means there must be an indented block after it.
In terms of making an interactive story, one could use input and if else statements to ask the viewer to type in custom responses and have the code ‘react’ in a way. For example:
name = input(“Pirate Bob: Hello there sailor, what’s your ship’s name? “)
age = int(input(“Pirate Bob: {} is a horrible name, but alas you are a good lookin chap. How old are you? “.format(name)))
print(“\n”)
print(“Pirate Bob: Wow, you’re {} years old??? Gimme a break”.format(age))
print(“\n”)
if age >=18:
print(“Pirate Bob: You’re old enough to work on my ship hah”)
else:
print(“Pirate Bob: You’re too young to do any good huh”)
… will output:
Pirate Bob: Hello there sailor, what's your ship's name? A: Shippy Ship Pirate Bob: Shippy Ship is a horrible name, but alas you are a good lookin chap. How old are you? A: 20 Pirate Bob: Wow, you're 20 years old??? Gimme a break Pirate Bob: You're old enough to work on my ship hah
The potential is real 🙂