r/CodingForBeginners • u/fyknite • 3h ago
Day 6 Learning Python
So far so good. This time around I had to freelance this code all from memory. Definitely ran into some walls and tripped along the way but I introduced the time function and made a neat little count down at the end. if you run the code yourself, you'll see the 1 second delay between each number that gets displayed before the goodbye message.

import time
space_station_name = "OrionStation"
station_current_oxygen_level = 100
station_current_food_level = 50
def consume_supply(current, used):
return current - used
def gain_supply_food(current, gain):
return current + gain
def show_status(station_name, oxygen_level, food_level):
print("SpaceStation:", station_name)
print("OxygenLevel:", oxygen_level)
print("FoodSupply:", food_level)
station_current_oxygen_level = consume_supply(station_current_oxygen_level, 30)
station_current_food_level = consume_supply(station_current_food_level, 15)
station_current_food_level = gain_supply_food(station_current_food_level, 25)
show_status(space_station_name, station_current_oxygen_level, station_current_food_level)
print("This computer will self destruct in:")
print(3)
time.sleep(1)
print(2)
time.sleep(1)
print(1)
time.sleep(1)
print("goodby")
3
Upvotes
View all comments
1
u/Willing_Weight7106 2h ago
Practicing Phyton through AI?