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

  • Comments

    # Symbol is very special in Python. It shadows everything that comes after it on the same line. It basically tells Python to ignore everything that comes after the # symbol. It is especially useful for typing human-readable comments inside the code and explaining what each part does.
    # This is a comment - this line will be ignored
    name = input()   # Read the name
    age = input()    # Read the age
    
    # Now we will print everything
    print(name, age, sep=' -- ')
    # The end of the program
    Python ignores all the blank lines. It also ignores all the lines that start with #. It also ignores all the text that comes after the # symbol.
     
    # a = input()
    print('hello')
    This program will just print hello. It won’t get the input() as that line starts with a #, and therefore, is treated as a comment.
     

    Challenge

    Write a program that would print each day of the week on a separate line (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, and Sunday) and write a comment next to each print statement indicating the number of that day (Monday - 1, Tuesday - 2, ... Sunday - 7).
     
    To check your solution you need to sign in
    Sign in to continue