CONDITIONAL STATEMENTS

IF/ELSE

Readers will notice that my coding style intentionally differs from standard PEP 8 conventions. This is by design. Because my primary programming languages are C and C++, I maintain a C-style approach when writing Python code using semicolons, C-like variable naming, and parentheses around conditional expressions, just as I would in C or C++. I also structure my statements and spacing in a way that resembles typical C/C++ syntax. This deliberate choice helps reinforce my familiarity with my core languages while allowing me to work fluidly across all three, and it keeps my development habits unified across the programming environments I use. Although Python encourages a different stylistic philosophy, preserving a consistent C/C++-like structure supports my personal workflow and keeps my muscle memory aligned with the environments in which I do most of my development.

#!/usr/bin/env python3

def main() -> None:
    
    age = int(input());
    votingAgeLimit = 18;
    
    if(age >= votingAgeLimit):
        print("Old enough to vote");
    else:
        print("Not old enough to vote");

if __name__ == "__main__":
    main();

IF/ELIF

The elif statement is used when multiple conditions need to be checked, allowing the program to run different code depending on which condition evaluates to true. It functions as an intermediate branch between if and else, making the control flow more structured and readable.

Last updated