I need to code something in Python for school, which if someone would say there name and what year there birthday it is, it will say hey ... you have been alive for ... venusyears, how much would someone want to do this for me? Need it done good..
#Assuming this is a venus year : https://www.universetoday.com/47900/length-of-year-on-venus/
from datetime import datetime
import sys
def get_venus_year(earth_years : int):
return round( (earth_years * 365)/225, 2)
#Take input from user
_name = input("Please Enter your Name: ")
try:
_yob = int(input("Please Enter your Birthyear (ex, 1970): "))
except ValueError:
print("Please enter your birth year in correct format")
#exit the program if invalid input is passed. You could add more checks around this so that a user cannot enter a birthyear >= current year
sys.exit()
#get current year
_cur_year = datetime.now().year
#calculate age (in years). This assumes that your birthday has already passed this year.
_earth_years = _cur_year - _yob
print(f"Hey {_name}, you have been alive for {get_venus_year(_earth_years)} venus years")
Wooow thank you a lot broCode:#Assuming this is a venus year : https://www.universetoday.com/47900/length-of-year-on-venus/ from datetime import datetime import sys def get_venus_year(earth_years : int): return round( (earth_years * 365)/225, 2) #Take input from user _name = input("Please Enter your Name: ") try: _yob = int(input("Please Enter your Birthyear (ex, 1970): ")) except ValueError: print("Please enter your birth year in correct format") #exit the program if invalid input is passed. You could add more checks around this so that a user cannot enter a birthyear >= current year sys.exit() #get current year _cur_year = datetime.now().year #calculate age (in years). This assumes that your birthday has already passed this year. _earth_years = _cur_year - _yob print(f"Hey {_name}, you have been alive for {get_venus_year(_earth_years)} venus years")
Might need some more tweaks but this would be the basic idea.

