fb pixel

Introduction to Python

  • Profound Academy

    • Status
      • 1
        Input and Output
      • 2
        Variables and Integer Arithmetic
      • 3
        Conditional Operators
      • 4
        Advanced Conditions - Nesting
      • 5
        Types and Variables
      • 6
        Strings
      • 7
        Lists
      • 8
        For Loops
      • 9
        While Loops
      • 10
        continue, break, while...else
      • 11
        String and List methods
      • 12
        Nested Loops
      • 13
        List Comprehension
      • 14
        Tuples and Sets
      • 15
        dict
      • 16
        Functions
      • 17
        Functions 2
      • 18
        Lambda and higher-order functions
      • 19
        Files

  • Security bouncer

    The security bouncer at a bar needs to keep track of the age. It’s a European bar, so the entrance is allowed for everyone 18 and older.
    For each visitor below 18, the program should tell them You are not allowed to get in. And for others, the program should welcome them telling Welcome to the best bar! Enjoy!.
    For each allowed visitor, the program will also get a number - how much they spent that day in the bar. The program should print the total revenue of the bar that night.
    The first line of the input contains a single number n - the number of visitors in the line. The next lines contain the age of the visitor, and their spending if they are allowed to the bar.
    For each customer, the program should print the appropriate message and how much the visitors spent in total at the very end.
    Input
    Output
    3 19 400 7 20 200
    Welcome to the best bar! Enjoy! You are not allowed to get in Welcome to the best bar! Enjoy! Total: 600
    Explanation:
    1. First visitor - 19 years old spends 400 euros
    1. Second visitor - 7 years old is not allowed
    1. Third visitor - 20 years old spends 200 euros
     
    To check your solution you need to sign in
    Sign in to continue