حالت آفلاین — محتوا از حافظهٔ کش نمایش داده می‌شود
همهٔ تمرین‌ها

محاسبه سال تولد کاربر

تمرین آسان 14014 visibility link download flag trending_up پربازدید

برنامه ای بنویسید که سن کاربر را از ورودی دریافت کند و سال تولد کاربر را محاسبه و چاپ کند

👨‍💻 1 ساعت قبل کاربر ناشناس این تمرین رو مشاهده کرد

پاسخ‌ها 44

from datetime import datetime

v= eval(input("pless inter you birthday day:"))
m= eval(input("pless inter you birthday mons:"))
y= eval(input("pless inter you birthday year:"))

d = datetime.now()
D, M, Y = d.day, d.month,  d.year

newday = D-v
if newday <0 :
    newday = -newday
    
newmons = M-m
if newmons < 0 :
    newmons = -newmons
    
print(f"{Y-y} year and {newmons} mons {newday} day")
from datetime import datetime
age = int(input('please enter your age: '))
this_year_m = datetime.now().year
this_year_sh = this_year_m - 621
birth_year_m = this_year_m - age
birth_year_sh = this_year_sh - age
print ("birth year in miladi Is: ",birth_year_m)
print ("birth year in shamsi Is: {} - {}".format(birth_year_sh,birth_year_sh-1))
function showYearBirthday(yourAge) {
    let nowYear = new Date().getFullYear()
    let showBirthday = (nowYear - yourAge)
    return showBirthday;
}
//test
// console.log(showYearBirthday(21))
def year_of_birthday(age):
    this_year=2024
    year_of_birthd= year_of_birthday - age
    return year_of_birthd
age=int(input('enter your age? \t'))
year_of_birthd=year_of_birthday(age)
print(f'if you are {age} year old, your year of birth is {year_of_birthd}')

ارسال جواب

جوابت را با Markdown بنویس و ثبت کن

×
بستن