Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #CS 171 by Shreedev Patel
- #Section 068
- import sys
- global G = -1.622
- global A = 50
- global V = 0
- global F = 150
- global s = 0
- print('Welcome to Lunar Lander Game.')
- while True:
- try:
- y = input('Do uou want to play level 1? (yes/no) \n')
- y = str(y)
- if y == 'yes':
- print("")
- break
- if y == 'no':
- sys.exit()
- def ask_fuel (current_fuel):
- while True:
- try:
- f= input('Enter units of fuel to use:\n')
- f= int(f)
- if (f<0) :
- print('Cannot use of negative fuel.')
- if current_fuel - f <= 0:
- print('Not enough fuel. Max fuel')
- else:
- break
- except ValueError:
- return f
- def play_level(name,G,fuel):
- print('Landing on the',name)
- print('Gravity is' ,G,'m/s^2')
- print('Initial Altitude',A,'meters')
- print('Initial Velocity',V,'m/s')
- print('Burning a unit of fuel causes 0.10m/s')
- while A>0:
- fuel = ask_fuel(current_fuel)
- F = F-fuel
- V=V+G+T*fuel
- A=A+V
- s=s+1
- names=['Moon','Earth','Pluto','Neptune','Uranus','Saturn','Jupiter','Mars','Venus','Mercury','Sun']
- gravity=[-1.622,-9.81,-0.42,-14.07,-10.67,-11.08,-25.95,-3.77,-8.87,-3.59,-274.13]
- Fuel= [150,5000,1000,1000,1000,1000,1000,1000,1000,1000,50000]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement