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

مصرف سوخت ماشین

تمرین آسان 2328 visibility link download flag

برنامه مقدار مسافت طی شده به کیلومتر و مقدار سوخت مصرف شده به لیتر را دریافت کند و با توجه به دستورالعمل زیر در خروجی چاپ کند که خودرو کم مصرف است یا پرمصرف.

اگر مصرف سوخت این خودرو کمتر از 7 لیتر در 100 کیلومتر بود: ماشین کم مصرف است

اگر مصرف سوخت خودرو بیشتر از 7 لیتر در 100 کیلومتر بود، ماشین پر مصرف است

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

پاسخ‌ها 17

# دستگاه محاسبه مصرف سوخت ماشین
while 1:
    i = float(input("Distance traveled (km): "))
    if i == 0:
        break
     
    j = float(input("Amount of fuel consumed (Lit): "))
    if (i or j) < 0:
        print("Error!")
        break

    if (i/j) > 14.2857142857: # این عدد حاصل دقیق 100/7 است
        print("The car is High consumption.")
    
    else:
        print("The car is Low consumption.")
while 1:
    try:   
        fuel_consumotion=float(input("enter the value of fuel consumption>>>>"))
        distance_covered=float(input("enter the value of distance covered>>>>"))
        result_in_100km=100*(distance_covered/fuel_consumotion)
        if result_in_100km<=7:
            print("low fuel consumption")
            break
        elif result_in_100km>7:
            print(" high fuel consumption")
            break
    except ValueError:
        print("your data must be integer our float")
while 1:
    try:   
        fuel_consumotion=float(input("enter the value of fuel consumption>>>>"))
        distance_covered=float(input("enter the value of distance covered>>>>"))
        result_in_100km=100*(distance_covered/fuel_consumotion)
        if result_in_100km<=7:
            print("low fuel consumption")
            break
        elif result_in_100km>7:
            print(" high fuel consumption")
            break
    except ValueError:
        print("your data must be integer our float")
s = float(input('Distance traveled (Km) : '))
l = float(input('Fuel consumed (Liter) : '))
x = (s/100) * 7
if l>x :
    print('It is a heavy-duty car .')
else :
    print('The car is low consumption .')
distance = float(input("مقدار مسافت طی شده (کیلومتر): "))
fuel_consumed = float(input("مقدار سوخت مصرف شده (لیتر): "))

consumption = (fuel_consumed / distance) * 100

if consumption < 7:
    print("ماشین کم مصرف است")
else:
    print("ماشین پر مصرف است")
پاسخ هوش مصنوعی Ai Python
class Gas:
	def __init__(self,liter,kilomater):
		self.liter=liter
		self.kilomater=kilomater
	def Solve(self):
		if self.kilomater/self.liter <100/7:
			return "low"
		else:
			return "high"

kilomater=float(input("enter kilomater:"))
liter=float(input("enter liter:"))
obj=Gas(kilomater, liter)
print(obj.Solve())

ارسال جواب

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

×
بستن