• Log in or sign up for an account here: https://www.sythe.org/login

Need help coding python dutch

Hichamelcuz

Member

Joined
Dec 11, 2019
Sythe Gold
69
Messages
80
Age
26
Location
Netherlands
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..
 
Heidy
Two Factor Authentication User
Hoover
Nitro Booster
Sythe's 15th Anniversary
Code:
#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.
 
Last edited:
Code:
#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.
Wooow thank you a lot bro
 
Runescape Gamblingrunescape gambling
Back
Top