diff --git a/Part-A/src/name_age.py b/Part-A/src/name_age.py index e34f00b..36d881c 100644 --- a/Part-A/src/name_age.py +++ b/Part-A/src/name_age.py @@ -1,49 +1,28 @@ -"""TODO: Replace with a one-line summary of the program's purpose (<73 chars). - -Input: - TODO: Replace with a major input, including its type and source. - TODO: Replace with another major input, or delete this TODO line. - TODO: Replace with another major input, or delete this TODO line. - -Process: - TODO: Replace with a major processing step. +""" +name_age.py -Output: - TODO: Replace with a major output, including its type and destination. +Prompts the user for their name and age, then calculates and displays +the birth year. Assumes the user has already had their birthday this year. -Typical usage example: - TODO: Replace with the input prompt and original name-input example. - TODO: Replace with the input prompt and original age-input example. - TODO: Replace with the resulting output from those inputs. +Author: [Your Name] +Course: IT 140 """ -# === Imports === -from datetime import date +from datetime import datetime -# === Constants === -CURRENT_YEAR = date.today().year # Get current year from system as integer +def main(): + """Prompt for name and age, then display the year the user was born.""" + current_year = datetime.now().year -# === Main Function === -def main() -> None: - """Run the name-age program.""" + name = input("What is your name? ") + age = int(input("How old are you? ")) - # Get user input. - # TODO: Replace with code to get user's name as a string. See zyBooks 1.3. - # TODO: Replace with code to get user's age as an integer. See zyBooks 2.6. + birth_year = current_year - age - # Calculate user's approximate birth year. - # TODO: Replace with code to process data. See zyBooks 1.16 & 1.17. + print(f"Hello {name}! You were born in {birth_year}.") - # Output personalized message with user's name and birth year. - # TODO: Replace with code to output formatted results. zyBooks 1.3 & 2.7. - -# === Main Guard === if __name__ == "__main__": main() - -# === References === -# TODO: Replace with an APA-style reference for a source you used, or delete. -# TODO: Replace with another APA-style reference, or delete this TODO line.