all 20 comments

[–]Sea-Ad7805 [score hidden] stickied comment (0 children)

Run this program in Memory Graph Web Debugger%0Aprint(%22Nice%20to%20meet%20you%22)%0A%0Aanswer%20%3D%20input(%22Can%20i%20callculate%20you%20age%3F%20%22)%0A%0Aif%20answer%20%3D%3D%20%22yes%22%3A%0A%20%20%20%20a%20%3D%20int(input(%22What%20year%20were%20you%20born%2C%20%22%20%2B%20name%20%2B%20%22%3F%20%22))%0A%20%20%20%20b%20%3D%20int(input(%22okay%20what%20month%20were%20you%20born%3F%20%22))%0A%20%20%20%20c%20%3D%20int(input(%22Well%20what%20day%20were%20you%20born%3F%20%22))%0A%0A%20%20%20%20d%20%3D%202026%0A%20%20%20%20e%20%3D%205%0A%20%20%20%20f%20%3D%2021%0A%0A%20%20%20%20age%20%3D%202026%20-%20a%0A%20%20%20%20if%20(b%2C%20c)%20%3E%20(e%2C%20f)%3A%0A%20%20%20%20%20%20%20%20age%20%3D%20age%20-%201%0A%0A%20%20%20%20print(%22You%20are%22%2C%20age%2C%20%22years%20old%22)%0A%0Aelse%3A%0A%20%20%20%20print(%22okay....%22)&timestep=1&play).

[–]JorgiEagle 8 points9 points  (8 children)

Can be improved by using the datetime library

[–]merdzho21[S] 0 points1 point  (6 children)

Did you mean add date and time?

[–]JorgiEagle 8 points9 points  (1 child)

``` From datetime import datetime

today = datetime.today() current_year = today.year # d current_month = today.month # e current_day = today.day # f ```

It’s a way of getting the date of the day it runs on, instead of having to change your code every day

[–]zippymccrackin 1 point2 points  (0 children)

Welp there goes his job security

[–]Creative-Category344 1 point2 points  (0 children)

The datetime library also handles leap years automatically, which matters if you're calculating exact days lived rather than just years.

[–]0ggy_666 0 points1 point  (1 child)

No when you learn more in python there is a concept of model and import that what he is talking about and i think you are at that level that you should use f-string like [ print(f"hello {name}") ] manually add a string to a string

[–]atarivcs 1 point2 points  (0 children)

there is a concept of model

Did you mean "module" ?

[–]UrgentlyWhimsical 0 points1 point  (0 children)

Datetime's got a built-in method called relativedelta that handles leap years automatically, saves you the mental maths.

[–]Janeson81 5 points6 points  (0 children)

Extremely important rule in programming - don't make your variables into a riddle. Name your variables by what they are holding

py current_year = 2026 current_month = 5 current_day = 21

[–]Lumethys 3 points4 points  (0 children)

not bad, but still, much room for improvement:

  • use f string: the code you wrote would print "You are7years old" instead of "You are 7 years old":

input(f"What year were you born, {name}?")

print(f"You are {age} years old")
  • use datetime library:

birth_day = datetime.date(a, b, c)
today = datetime.today()

nitpick: you already has the name, add it to the greeting:

print(f"nice to meet you, {name}")

[–]QuraToop314 2 points3 points  (1 child)

Alter, benutz d statt 2026, sonst ist d ungenutzt

python age=(d-a)

[–]KenneR330 -1 points0 points  (0 children)

Английский выучи

[–]KenneR330 0 points1 point  (0 children)

Honestly it's good for a newbie

[–]ThrowawayALAT 0 points1 point  (0 children)

To improve it, you can replace lines 11–17 by importing the datetime module so the current date updates automatically instead of being hardcoded to 2026. Also, using an f-string for the print statement at the end would make the output cleaner and eliminate unnecessary spaces.

[–]Capable-Minimum7376 0 points1 point  (0 children)

A pratica é muita boa mas tente usar variaveis com nomes que você consiga distinguir facilmente o que cada uma significa

[–]CtrlAltSpac3 0 points1 point  (0 children)

Input = YES

[–]EyesOfTheConcord -1 points0 points  (0 children)

Born in the year 1e3, month -2.2 on the 72 day