Last active
March 26, 2024 21:00
-
-
Save adrianyorke/2b338cfd8f3f17e154f8e100782dcf30 to your computer and use it in GitHub Desktop.
Simple game - 10 guesses to work out force required for takeoff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import random | |
# Computer Space Games by Usborne Publishing | |
# https://drive.google.com/file/d/0Bxv0SsvibDMTNlMwTi1PTlVxc2M/view?resourcekey=0-kaU6eyAmIVhT3_H8RkHfHA | |
def display_banner(title): | |
clear_screen_cmd = "clear" if os.name == "posix" else "cls" | |
os.system(clear_screen_cmd) | |
print("="*len(title)) | |
print(title) | |
print("="*len(title)) | |
display_banner(title="Starship Take-Off") | |
mass = random.randint(1,40) | |
gravity = random.randint(1,20) | |
weight = mass * gravity | |
print(f"Gravity: {gravity}") | |
for i in range(1,10,1): | |
if i > 1: | |
print(", TRY AGAIN") | |
force_guess = int(input(f"TYPE IN FORCE (attempt {i} of 10): ")) | |
if force_guess > weight: | |
print("TOO HIGH",end="") | |
continue | |
elif force_guess < weight: | |
print("TOO LOW",end="") | |
continue | |
print("GOOD TAKE OFF") | |
exit() | |
# Failed | |
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