Skip to main content
Query

My First LibreTexts Page

  • Page ID
    37837
  • How to create Lists in Python (Example Heading 1)

    Authors can use the LibreTexts Platform to create pages on a multitude of subjects and topics. In this tutorial, we will show you how an author can use the various features of the plugin to display information in a way that best suits their intent.

    How To Print the Code and Output from a Script

    example_list = ['apple', 'cherry', 'grape']
    print(example_list)
    ['apple', 'cherry', 'grape']
    

    How To Print Code with just Input

    example_list = ['apple', 'cherry', 'grape']
    print(example_list)

    How To Print Code with just the Output (no run button)

    example_list = ['apple', 'cherry', 'grape']
    print(example_list)
    ['apple', 'cherry', 'grape']
    

     

     

    How To Create Numpy Arrays in Python (Example Heading 2)

    Just like your favorite text editor, packages and libraries can also be imported. If there is a package of library that you would like to use and is not already available, simply email our team or open an issue (more information available on the dialogue box). 

    import numpy as np
    np.array([[1,2,3,4], [5,6,7,8], [9,10,11,12], [13,14,15,16]])
    array([[ 1,  2,  3,  4],
           [ 5,  6,  7,  8],
           [ 9, 10, 11, 12],
           [13, 14, 15, 16]])