1

ho i making the random number be below the random number before.

 if Airplane==1:
 while icounter<4:
    ifuelliter=random.randrange(1,152621)
    #litter/kilometer
    LpK=152620/13500
    km=LpK*ifuelliter


    ipca=random.randrange(0,50)
    ipcb=random.randrange(0,50)
    ipcc=random.randrange(0,812)


    #3D space distance calculation
    idstance= math.sqrt((icba-ipca)**2 + (icbb-ipcb)**2 + (icbc-ipcc)**2)

    totaldist=km-idstance

    if totaldist>0:
          print "You have enoph fuel to get to New York AirPort"
          print ifuelliter,LpK,km,ipca,ipcb,ipcc,idstance
          icounter=3

    if totaldist<=0:

         print "You dont have enoph fuel to get to New York AirPort please go to the nearest one or you will die"
         print ifuelliter,LpK,km,ipca,ipcb,ipcc,idstance
         icounter=icounter+1

whati mean that the "ipca , ipcb , ipcc," i need that they will grow down and not chust a other number.

1 Answer 1

1

Just set the second parameter of randrange with the previous value:

import random
a = random.randrange(0,50)
b = random.randrange(0,a)
while b > a:
    b = random.randrange(0,a)

By the way, be careful if your indenting style at the beginning of your code

if Airplane == 1:
while ....

Should be

if Airplane == 1:
    while ....
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.