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

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

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

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

👨‍💻 7 ساعت قبل کاربر ناشناس این تمرین رو مشاهده کرد
👨‍💻 21 ساعت قبل User 11172 این تمرین رو مشاهده کرد

پاسخ‌ها 90

#عملیات بدست اوردن تفاضل بین سن پدر و شما
#سن پدر پرسیده میشود
fader =int (input('enter youer fader age; '))
#سن شما پرسیده می شود
you = int (input('enter youer you age; '))
#تفاضل سن پدر و شما
print (fader - you)
#تمرین سایت کدبزن
#2 - تفاضل سن پدر و پسر
#گرفتن سن پدر از کاربر
af = int(input("enter the age of father:"))
#گرفتن سن پسر از کاربر
bs = int(input("enter the age of son:"))
#بدست آوردن اختلاف سن پدر و پسر
print ( af - bs )
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 بنویس و ثبت کن

×
بستن