# Lab 2 Solution # Jason Witherell # ETGG1801-01 (and -02) # 8/20/2017 ############################################ # Part I: ASCII ART # ############################################ print("Part I: ASCII Art\n=================") print("""Using a triple-quoted string /\\ *--------* / \\ | | / \\ | *-----* / \\ *---* | / \\ | *----* / \\ *-------* | | | \" \"-* | | \"\"\"\" | | || | | || ================================================""") print("Using multiple print statements:") print(" /\\ *--------*") print(" / \\ | |") print(" / \\ | *-----*") print(" / \\ *---* |") print(" / \\ | *----*") print(" / \\ *-------* | ") print(" | | \" \"-*") print(" | | \"\"\"\"") print(" | | ||") print(" | | ||") print(" ================================================") ############################################ # Part II: Gravitational Calculator # ############################################ print("\n\nPart II: Gravitational Calculator\n=================================") mass1 = float(input("\tEnter the mass of the first body (in kg): ")) mass2 = float(input("\tEnter the mass of the second body (in kg): ")) distance = float(input("\tEnter the distance between the objects (in m): ")) gravitational_constant = 6.67384e-11 force = round(gravitational_constant * mass1 * mass2 / (distance ** 2), 5) print("\tThe gravitational force between these two objects is", force, "Newtons.") ############################################ # Part III: Health Bar # ############################################ print("\n\nHP Bar\n======") hp_cur = int(input("\tEnter the current hp: ")) hp_max = int(input("\tEnter the maximum hp: ")) bar_size = 40 num_plus = int(round(bar_size * hp_cur / hp_max)) num_space = bar_size - num_plus print("\t/" + "-" * bar_size + "\\") print("\t|" + "*" * num_plus + " " * num_space + "|") print("\t\\" + "-" * bar_size + "/") input("Press Enter to continue")