How to sequence LEDs only once, then off

Hi I'm new to programming, and my first question is, can I put a small code into my setup? So it only runs the code once, and before it does any other code I write later? So say I turn the power in to my circuit, the arduino boots up, does the "entry" code, then continues doing any other codes in the loop.

My second question is how can I turn on one led at a time, the. Have them turn off together? I've tried for loops, if/else, delays, everything I know so far. The purpose of this is kind of like, the system is ready, type thing. I want a 2 second delay, then the first led turns on, then one second later led 2 turns on. Then one more second later led 3 turns on. They will all stay on another 3 seconds after that, then turn off simultaneously, with no loops. Just a one and done thing. Sorry of this is confusing I dint know how else to put it. Any help will be great!

I'm using an arduino nano. V3 328
Thanks again!

Hi, welcome to this forum,

The setup function runs once when you press reset or power the board and it is possible to use it to run any kind of code.

Normally I would advise you to use the delay -function as little as possible, arduino does nothing else but waiting when you call it, but it probably isn’t problematic in setup.

// the setup function runs __once__ when you press reset or power the board
void setup() {
  for (int pin = 2; pin <= 10; pin ++){ // I've chosen pins 2-10 as example
    pinMode (pin, OUTPUT);              // initialize pins needed as output.
    delay(2000);                        // Wait for 2 seconds
    digitalWrite(pin, HIGH);            // Turn specific led on
   
  }
  delay(2000);                           // Wait for 2 seconds to see the led last turned on (!)
                                         // all leds are on... now turn 'm off
  for (int pin = 2; pin <= 10; pin ++){
    digitalWrite(pin, LOW);              // turn led off
    // delay(125);                       // You could... add a small delay for visual effects
  }
}

void loop() {
  // part of your program that keeps running.
}