From 8ab3660e7f3586b806bcb7e60cbef3bf61d8f5de Mon Sep 17 00:00:00 2001 From: mollusk Date: Mon, 21 Sep 2020 21:45:21 -0700 Subject: [PATCH] Colorize output --- cost-of-smokes.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/cost-of-smokes.py b/cost-of-smokes.py index 5f419a4..8f217bb 100644 --- a/cost-of-smokes.py +++ b/cost-of-smokes.py @@ -4,6 +4,8 @@ #output day, week, month year costs import os import math +import ciglib +from ciglib import fgColor cost = None packs = None @@ -40,32 +42,32 @@ while True: os.system('clear') break -print("Your cigarettes cost $" + format(cost/20, '.2f'), "each") +print(fgColor.RED,"Your cigarettes cost $" + format(cost/20, '.2f'), "each", fgColor.NC) print() -print("You smoke: ") -print(math.ceil(20 * packs), "per day") -print(math.ceil(20 * packs * 7), "per week") -print(math.ceil((20 * packs * 365)/12), "per month") -print(math.ceil(20 * packs * 365), "per year") +print(fgColor.CYAN,"You smoke: ",fgColor.NC) +print(fgColor.YELLOW,math.ceil(20 * packs), "cigarettes per day", fgColor.NC) +print(fgColor.YELLOW,math.ceil(20 * packs * 7), "cigarettes per week",fgColor.NC) +print(fgColor.YELLOW,math.ceil((20 * packs * 365)/12), "cigarettes per month",fgColor.NC) +print(fgColor.YELLOW,math.ceil(20 * packs * 365), "cigarettes per year", fgColor.NC) print() -print("This costs you: ") +print(fgColor.CYAN,"This costs you: ",fgColor.NC) tempCost = format(cost * packs, '.2f') tempHours = calcHours(tempCost) -print("$" + tempCost, "and", tempHours, "hours per day") +print(fgColor.GREEN,"$" + tempCost, "and", tempHours, "work hours per day",fgColor.NC) tempCost = format(cost * packs * 7, '.2f') tempHours = calcHours(tempCost) -print("$" + tempCost, "and", tempHours, "hours per week") +print(fgColor.GREEN,"$" + tempCost, "and", tempHours, "work hours per week",fgColor.NC) tempCost = format((cost * packs * 365)/12, '.2f') tempHours = calcHours(tempCost) -print("$" + tempCost, "and", tempHours, "hours per month") +print(fgColor.GREEN,"$" + tempCost, "and", tempHours, "work hours per month",fgColor.NC) tempCost = format(cost * packs * 365, '.2f') tempHours = calcHours(tempCost) -print("$" + tempCost, "and", tempHours, "hours per year") +print(fgColor.GREEN,"$" + tempCost, "and", tempHours, "work hours per year",fgColor.NC)