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
      • 7
      • 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
      • 16
      • 17
        Functions 2
      • 18
        Lambda and higher-order functions
      • 19

  • Advanced printing - sep

    So far, we’ve used print() statements with different arguments, and the program printed those separated by a space. print('abc', 'def', 2) would result in abc def 2.
    What if we want to separate the values with a * instead of a space. This is possible by providing a sep parameter to print().
    print('hello', 'my', 'name is', 'Python', sep='*')
    This program would print hello*my*name is*Python. sep can be any textual value. It can be a phrase (this is a separation, hey hey, etc), it can consist of symbols, and it can even be an empty text sep=''. In the case of an empty text, print would output the values concatenated to each other.
    print('hello', 'my', 'name is', 'Python', sep='')
    dash = '--'
    print('hello', 'my', 'name is', 'Python', sep=dash)
    This would result in:
    hellomyname isPython
    hello--my--name is--Python


    You are given 3 inputs - a year, a month, and a day. You need to output the date in the format year-month-day.
    2022 05 10
    To check your solution you need to sign in
    Sign in to continue