Scripting

How to Check Python Version in Jupyter Notebook?

To check the Python version in your Jupyter notebook, first import the python_version function with “from platform import python_version“. Then call the function python_version() that returns a string with the version number running in your Jupyter notebook such as “3.7.11”. You can try this yourself in our interactive Jupyter notebook: Check Version Information Using sys …

How to Check Python Version in Jupyter Notebook? Read More »

What’s the Difference Between ‘py’ and ‘python’ in the Terminal?

Problem If you run Python in your terminal or shell, you may have realized that there are two ways to do so: using the “python” command and using the “py” command. What’s the difference? Example Say, you want to check your Python version. You can run both commands and the output is different! Here’s using …

What’s the Difference Between ‘py’ and ‘python’ in the Terminal? Read More »

How to Print a NumPy Array Without Brackets in Python?

Note that this tutorial concerns NumPy arrays. To learn how to print lists without brackets check out this tutorial: How to Print a List Without Brackets in Python? Problem Formulation Given a NumPy array of elements. If you print the array to the shell using print(np.array([1, 2, 3])), the output is enclosed in square brackets …

How to Print a NumPy Array Without Brackets in Python? Read More »

How to Print a Tuple Without Parentheses in Python?

Problem Formulation Given a tuple of elements. If you print the tuple to the shell using print((1, 2, 3)), the output is enclosed in parentheses like so: (1, 2, 3). But you want the list without brackets like so: 1, 2, 3. How to print the tuple without enclosing parentheses? Method 1: Unpacking The asterisk …

How to Print a Tuple Without Parentheses in Python? Read More »

How to Print a Dictionary Without Brackets in Python?

Problem Formulation Given a dictionary of key value pairs in Python. If you print the dictionary to the shell using print({‘a’: 1, ‘b’: 2}), the output is enclosed in curly brackets (braces) like so: {‘a’: 1, ‘b’: 2}. But you want the dictionary without brackets like so: ‘a’: 1, ‘b’: 2. How to print the …

How to Print a Dictionary Without Brackets in Python? Read More »

Python Print Without Extra Newline When Reading a File

Problem Formulation Given a file with name file.txt and the following content: hi finxters! ๐Ÿ™‚ You created a Python script that reads the file line-by-line and prints each line to the shell like so: But the output unexpectedly adds an extra newline to each line so you obtain the following output on the Python shell: …

Python Print Without Extra Newline When Reading a File Read More »