Snippets

Kevin Pichette Hovercrafts

Updated by Kevin Pichette

File hovercrafts.py Modified

  • Ignore whitespace
  • Hide word diff
 # Explanation
 # If you only had 5 hovercrafts, you spent 21,000,000 to operate but only made
 # 15,000,000.
+def main():
+    hc = int(input("Hovercrafts sold: "))
+#   hcs = int(hc)
+    is_hover(hc)
 
-hc = input("Hovercrafts sold: ")
-hcs = int(hc)
+def is_hover(hcs):
+    build = 2000000
+    eachhc = 3000000
 
-build = 2000000
-eachhc = 3000000
+    ins = 1000000
 
-ins = 1000000
+    a = hcs * eachhc
+    spent = (10 * build) + ins
 
-a = hcs * eachhc
-spent = (10 * build) + ins
+    amtmd = "Amount made: "
+    print(f'{amtmd}{a}')
 
-amtmd = "Amount made: "
-print(f'{amtmd}{a}')
+    if a == spent:
+        print("Broke Even")
+    elif a >= spent:
+        print("Profits")
+    elif a <= spent:
+        print("Loss")
 
-if a == spent:
-    print("Broke Even")
-elif a >= spent:
-    print("Profits")
-elif a <= spent:
-    print("Loss")
+main()
Updated by Kevin Pichette

File hovercrafts.py Modified

  • Ignore whitespace
  • Hide word diff
 # A string that says "Profit', 'Loss', or 'Broke Even'.
 
 # SAMPLE INPUT
-# 5
+# 7
 
 # SAMPLE OUTPUT
 # Loss
 print(f'{amtmd}{a}')
 
 if a == spent:
-    print("Broke even")
+    print("Broke Even")
 elif a >= spent:
-    print("Profit")
+    print("Profits")
 elif a <= spent:
     print("Loss")
Updated by Kevin Pichette

File hovercrafts.py Modified

  • Ignore whitespace
  • Hide word diff
 print(f'{amtmd}{a}')
 
 if a == spent:
-    print("Breoke even")
+    print("Broke even")
 elif a >= spent:
     print("Profit")
 elif a <= spent:
Created by Kevin Pichette

File hovercrafts.py Added

  • Ignore whitespace
  • Hide word diff
+# You run a hovercraft factory. Your factory makes ten hovercrafts in a month.
+# Given the number of customers you got that month, did you make a profit?
+# It costs you 2,000,000 to build a hovercraft, and you are selling them for
+# 3,000,000. You also pay 1,000,000 each month for insurance.
+
+# TASK:
+# Determine whether or not you made a profit based on how many of the ten
+# hovercrafts you were a le to sell that month.
+
+# INPUT FORMAT:
+# An integer that represents the sales that you made that month.
+
+# OUTPUT FORMAT
+# A string that says "Profit', 'Loss', or 'Broke Even'.
+
+# SAMPLE INPUT
+# 5
+
+# SAMPLE OUTPUT
+# Loss
+
+# Explanation
+# If you only had 5 hovercrafts, you spent 21,000,000 to operate but only made
+# 15,000,000.
+
+hc = input("Hovercrafts sold: ")
+hcs = int(hc)
+
+build = 2000000
+eachhc = 3000000
+
+ins = 1000000
+
+a = hcs * eachhc
+spent = (10 * build) + ins
+
+amtmd = "Amount made: "
+print(f'{amtmd}{a}')
+
+if a == spent:
+    print("Breoke even")
+elif a >= spent:
+    print("Profit")
+elif a <= spent:
+    print("Loss")
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.