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

تفاضل سن پدر و پسر

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

برنامه ای بنویسید که سن پدر و پسری را از ورودی دریافت کند و تفاضل (تفریق) آنها را در خروجی چاپ کند

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

پاسخ‌ها 87

def get_age(father_age, son_age):
    fa_bo_age = father_age - son_age
    if father_age < son_age:
        print("The father's age cannot be less than the son's age, so please enter the correct information!!")
        get_age(father_age=int(input("Please enter the father age: ")),son_age=int(input("Please enter the son age: ")))
    else:
        print(f"The result of the age difference between father {father_age} and son {son_age}, {fa_bo_age} is years.")
get_age(father_age=int(input("Please enter the father age: ")), son_age=int(input("Please enter the son age: ")))
fatherAge=int(input("سن پدر را وارد کنيد:"))
sonAge=int(input("سن پسر را وارد کنيد:"))
differenceBetweenSonAndFather=fatherAge-sonAge
print("اختلاف سن پدر و پسر:",differenceBetweenSonAndFather)

ارسال جواب

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

×
بستن