×

How to run a Program in Python

How to run a Program in Python

Writing a program in Python is an easy task, beginners who are ready to kickstart their career in the world of programming can create wonders if they practice basic programs every day.

Python is a simple and easy-to-learn language. The feature that makes it popular is its understandable syntax. So, a person from a non-technical background will also get an idea of what exactly our objective is.

Python is the most preferred language in all the big leading companies which are the tech giants of the IT Industry. Some widely used applications such as YouTube & Dropbox use this language.

Since python is a high-level language there is no need to worry about the details of memory management in the program. Also, it’s interactive in nature so the users can directly execute their chunks of code on the interpreter.

So, the process remains the same, work on building your logic, acquire a good knowledge of the rules that you need to take care of while writing a program, and keep exploring!

Python has a huge library of modules that can provide solutions to complex problems through its in-built components.

Once you have written the code the next step is to execute the program and display the output.

The program we will use to understand the execution is given below-

 a=int(input("Enter 1st number: "))         #obtaining first value
 b=int(input("Enter 2nd number: "))       #obtaining second value
 c=a+b                                     #performing addition
 print("Sum of a and b is {}".format(c))  #displaying the result 
  1. Running a program in Command Prompt.

Command Prompt acts as an interpreter in Windows and on specifying the correct path and by using the necessary commands, we can perform the required tasks. Typing 'cmd' in the search area of the taskbar will show the command prompt option and then we can start working on it.

  • Open Command Prompt from the taskbar and run your file by specifying the file name.
  • Make sure you provide the correct destination of your file.
  • Running a program in Python IDLE.

IDLE is Python's Integrated Development & Learning Environment. It works in a similar manner on all the platforms and has this feature of an interactive interpreter.

Moreover, Python IDLE has a shell window and an editor window.

In Python IDLE, each statement is executed and the output is displayed for every line of a program.

  • Running a program in Spyder IDE

Spyder IDE is used for scientific programming in python and it is pre-installed in Anaconda Navigator. Packages like NumPy, matplotlib, scipy, and pandas are integrated with this.

It is used by data analysts, scientists, and engineers. It provides advanced editing options and great visualization tools.

  • The code given below shows how we can perform addition in python. Once you have written the code. Go to the file and click on 'Save As'. Save your file in the destination folder with .py extension.
  • Click on ‘Run’ or F5.

In the output window, you can enter the values and get the output.

  • Running a program in Jupyter Notebook

Jupyter Notebook amalgamates all our work in a manner that it looks well-presented and easy to comprehend. Data Science & Machine Learning projects are mostly made on this platform as new components can be easily integrated with the existing ones. Various processes like reading & fetching data from a file, data cleansing & pre-processing, exploratory data analysis, and visualization can be done on Jupyter Notebook.

Jupyter Notebook is that platform where business problems of different domains can be understood and based on the insights, we can report the required solution.

  • Open Jupyter Notebook
  • Write your code in the provided cells.
  • Once you have written the code, Go to ‘File’ and click on ‘Save As’.
  • Click on ‘Run’ or ‘Shift+Enter’ to run your code.
  • On execution, it will ask you to enter the values.
  • On entering the values, the expected output is displayed.

So, these are the four ways of executing a program in Python. Being a computer geek, we must make an effort to understand the functionality of all the four approaches (Running a program on command prompt, Running a program on Python IDLE, Running a program on Spyder IDE, and Running a program on Jupyter Notebook.)


Related Topics

Python Function

Python Function A Python function is a reusable, organized block of code that is used to perform the specific task. The functions are the appropriate way to divide an extensive program into a...

7 minutes read.

Python Fit Transform

In machine learning, fit (), transform(), fit transform () methods are provided by scikit learn package. This package is used in model fitting and data processing. These methods are implemented...

2 minutes read.

Python Pickle

The pickle is a module that enables serialization and de-serialization of the structure of the object in python. Pickling is the process that uses the protocols to convert the Python...

5 minutes read.

Python Memory Management

In order to manage memory, Python uses a private heap that contains all of its data structures and objects. The Python memory manager is responsible for the internal management of...

11 minutes read.

Yield vs Return in Python

In this article, you will learn about " Yield " and " Return " in Python. You will also understand the difference between " Yield " and " Return "...

6 minutes read.

Python History

Python is one of the top trending, widely-used programming languages. Python is a general-purpose programming language. Python language is known for its features. Some features are given below: SimplisticFree and open...

4 minutes read.

How to get current date in python?

How to get current date in python? In Python programming language, date and time are not just a data form, but it is possible to import a method called datetime to operate...

3 minutes read.

How to check data type in python

The data type represents the nature of a variable; it determines what kind of data it can store and what operations can be carried out on it. There are five...

4 minutes read.

Get index of element in array in python

Index : Index is a number where the element is located in the given list. In other words it is the position of the element in the list. Index can also...

4 minutes read.

Is Python Case-sensitive when Dealing with Identifiers

Yes, Python is a case-sensitive language while dealing with identifiers. Python is one of the top trending, widely-used programming languages. Python is a general-purpose programming language. It is a case-sensitive...

6 minutes read.

List Subtract in Python

The List is one of the most unique Data Structures in Python. It is generally used to store multiple values in just one single variable. It is one of the...

4 minutes read.

Exrex Python

Python: Python is an interactive and more accessible language than any other programming language. The python programming language uses a variety of libraries to perform the operations in a faster...

4 minutes read.

Python Generator

Python Generator: A Function is said to be a Python Generator that produces or generates a sequence of results. A Python Generator maintains its native state to work so that...

6 minutes read.

Difference between Perl and Python

Control and presently utilized for a great many undertakings, including framework organization, web improvement, network programming, and GUI improvement, and the sky is the limit from there. About Perl? Perl is a...

4 minutes read.

Python Queue

Python Queue There are various day to day activities where we find ourselves engaged with queues. Whether it is waiting in toll tax lane or standing on the billing counter for...

7 minutes read.

Add Element to Tuple in Python

Python: Popular high-level, all-purpose programming language Python. The new version of the Python programming language, Python 3, is used for all software applications, including web development. Python is the best programming...

4 minutes read.

Iterate a Dictionary in Python – Part 2

In this tutorial, we will learn above various methods used to Iterate a Dictionary in Python. Dictionary: In Python, a dictionary is an unordered collection of data values that is used to...

3 minutes read.

Python Maurer Rose and Rhodonea Curves

In this tutorial, in Python we will make a Maurer Rose example and Rhodonea Curve example. Before we continue to see what precisely is maurer rose or a rhodonea bend...

10 minutes read.

Python Dictionary copy() method

Python Dictionary copy() method The dictionary.copy () method in Python returns a copy of the specified dictionary. Syntax dictionary.copy () Parameter NA Return None Example 1 # Python program explaining # the dictionary.copy() method # initialising the dictionary ...

1 minute read.

GUI to Shut down, Restart and Logout from the PC using Tkinter in Python

GUI: One of the most significant factors that increased the usability of computer and digital technologies for common, less tech-savvy users is likely the development and widespread adoption of GUIs. GUIs...

4 minutes read.