Skip to content

Instantly share code, notes, and snippets.

@seantibor
Created October 27, 2020 02:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seantibor/d14562af24329a4e403bfe6e6e511702 to your computer and use it in GitHub Desktop.
Save seantibor/d14562af24329a4e403bfe6e6e511702 to your computer and use it in GitHub Desktop.
#!/bin/usr/env python3
"""
STARSHIP TAKEOFF
Adapted from Usborne Book Computer Spacegames
https://drive.google.com/file/d/0Bxv0SsvibDMTNlMwTi1PTlVxc2M/view
You are a starship captain. You have crashed your ship on a
strange planet and must take off again quickly in the alien
ship you have captured. The ship's computer tells you the
gravity on the planet. You must guess the force required for a
successful take off. If you guess too low, the ship will not lift
off the ground. If you guess too high, the ship's fail-safe
mechanism comes into operation to prevent it being burnt
up. If you are still on the planet after ten tries, the aliens will
capture you.
"""
from random import randint
print("STARSHIP TAKE-OFF")
"""
Computer selects two numbers - one between 1 and 20
to be put in G, the other beteween 1 and 40 to be put in W
"""
g = randint(1, 20)
w = randint(1, 40)
# Multiplies the number in G by the number in W. Puts the result in r.
r = g * w
# prints gravity and number in g
print(f"GRAVITY= {g}")
print("TYPE IN FORCE")
for i in range(10):
f = int(input()) # Stores your number in f
if f > r:
print("TOO HIGH")
elif f < r:
print("TOO LOW")
else:
break
if i < 9:
print("TRY AGAIN")
if f == r:
print("GOOD TAKE OFF")
else:
print()
print("YOU FAILED -")
print("THE ALIENS GOT YOU")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment