CodeSolved

A comprehensive source of programming questions and exercises

Car fuel consumption

Practice Easy 120/ Download 878 Views

The program receives the amount of distance traveled to kilometers and the amount of fuel consumed in liter and prints according to the following instructions, whether the car is low or high.

If the fuel consumption of the car was less than 7 liters per 100 km: the car is low -consumption

If the car's fuel consumption was more than 7 liters per 100 kilometers, the car is consuming

12 Answers

This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
d = float(input("Distance (km): "))
f = float(input("Fuel (liters): "))
print("Fuel-efficient" if f / d * 100 < 7 else "Fuel-inefficient")
masafat = float(input("enetr your km:"))
sokjt  = float(input("enter your litr:"))

if masafat / sokjt < 100/7:
    print("mashin kammawraf")
if masafat / sokjt > 100/7:
    print("mashin por masraf")
m = int(input('lotfan masafat tey shode ba mashin ra be kiloometr vared konid'))
s = int(input('lotfan sookht masraf shode be litr ra vared konid'))
n = m/s
if n > 100/7:
    print ('por masraf ast')
else:
    print('kam masraf ast')
k_m=int(input("inter your dictsnce: "))
fule=int(input("inter your fule: "))
carfule=[round(k_m/fule),round(7/100)]
car=map(lambda num:num<=round(7/100),carfule)
if all(car)==True:
    print("this good car")
else:
    print("this wrong car")
User 943 Download Python
if int(input('حجم مصرف بنزین:'))/int(input('مسافت طی شده:'))<7/100:
    print(' کم مصرف')
else:
    print('پر مصرف')
masafat = float(input("masafate tey shode (km): "))
soukht = float(input("meghdare soukhte masraf shode(lit): "))
natije = (masafat * 7) / 100
if soukht <= natije:
    print("kam masraf")
else:
    print("por masraf")
# Machine
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: # This number is the exact result of 100/7
        print("The car is High consumption.")
    
    else:
        print("The car is Low consumption.")
<< Previous page 1 2 Next page >>

Submit answer

Submitting answers is currently unavailable.

Related content

Detection using AI
×
×
Close