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

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

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

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

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

پاسخ‌ها 87

# مرحله اول سن پسر را دریافت میکنیم 
pesar = int(input('sen pesar  ra vared konid : '))
# در مرحله دوم سن پدر را دریافت میکنیم 
pedar = int(input('sen pedar  ra vared konid : '))
# در مرحله سوم تفاضل بین سن هارا محاسبه میکنیم 
tafazol  = ( pedar - pesar )
# در مرحله چهارم پاسخ بدست امده را پرینت میکنیم
print ( '=' , tafazol )

# Calculate the age difference between father and son
fatherAge = int(input("Enter the father age. "))
sonAge = int(input("Enter the son age. "))
formula = (fatherAge - sonAge)
output = print("The age difference between father and son is",formula,"years.")
father_age = int(input("Enter father's age:")) 
son_age = int(input("Enter son's age:"))

if son_age > father_age :
    ( print("It is not possible that son being older than his father."))
    
elif son_age == father_age :
    ( print("Father and son cannot have the same age."))
    
elif son_age < father_age :
    age_differece = father_age - son_age 
    print(f"The father is {age_differece} years older than his son.")
fatherage, sonage = [int(x) for x in input(
    "enter father's age nad son's age (seperated with ','):").split(',')]
print(f"The age difference between father and son is equal to {fatherage - sonage}")
pedar=int(input('sen bedar ra vared konid?'))
pesar=int(input('sen besar ra vared konid?'))
x=pedar-pesar
print(f'age sen pedar {pedar} va sen pesar {pesar} tafavot seni onha {x}')
#گرفتن سن پدر و پسر
F=int(input('Enter Your Age Father:'))
S=int(input('Enter Your Age Son:'))
#تفریق سن انها و چاپ نتیجه جواب
print( F - S )

ارسال جواب

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

×
بستن