Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions Part-A/src/name_age.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
"""TODO: Replace with a one-line summary of the program's purpose (<73 chars).
"""This program asks for a name and age and calculates the birth year.

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.
Name - string entered by the user.
Age - integer entered by the user.
Current year - integer provided by the system.

Process:
TODO: Replace with a major processing step.
Calculate the birth year by subtracting the user's age from the current year.

Output:
TODO: Replace with a major output, including its type and destination.
personalized message with the user's name and birth year - string displayed in the console.

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.
What is your name? Alex
How old are you? 24
Hello Alex! You were born in 2001.
"""

# === Imports ===
Expand All @@ -29,14 +29,15 @@ def main() -> None:
"""Run the name-age program."""

# 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.
name = input("What is your name? ")
age = int(input("How old are you? "))

# Calculate user's approximate birth year.
# TODO: Replace with code to process data. See zyBooks 1.16 & 1.17.
birth_year = CURRENT_YEAR - age

# Output personalized message with user's name and birth year.
# TODO: Replace with code to output formatted results. zyBooks 1.3 & 2.7.
print(f"Hello {name}! You were born in {birth_year}.



# === Main Guard ===
Expand Down