Introduction to Python Programming: Installation, Scripting, and Basic Concepts, Lecture notes of Semantics of Programming Languages

An introduction to python programming, covering installation, using the interactive shell, and creating and running python scripts. It explains what python is, its history, key features, and application areas such as data science, machine learning, web development, and game development. The document also includes instructions for installing python on windows, linux, and macos, and discusses python editors and ides.

Typology: Lecture notes

2024/2025

Available from 11/24/2025

prateek-7
prateek-7 🇮🇳

3 documents

1 / 23

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Introduction to Python,
Installation, Using Interactive
Shell, Creating Saving and
Running Python Script
Presented by
Mohd Shuaib
Assistant Professor
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17

Partial preview of the text

Download Introduction to Python Programming: Installation, Scripting, and Basic Concepts and more Lecture notes Semantics of Programming Languages in PDF only on Docsity!

Introduction to Python,

Installation, Using Interactive

Shell, Creating Saving and

Running Python Script

Presented by Mohd Shuaib Assistant Professor

What is Python

  • (^) Python is a general purpose programming language applied in scripting roles.
  • (^) So it is a programming language as well as scripting language.
  • (^) Python is also called interpreted language.
  • (^) A scripting language is a programming language that employs a high-level construct to interpret and execute one command at a time. In general, scripting languages are easier to learn and faster to code in than more structured and compiled languages such as C and C++.
  • (^) Compiled languages are converted permanently into executable files before they are run. In contrast, scripting languages are typically converted into machine code on the fly during runtime by a program called an interpreter.
  • (^) Python is a widely used general-purpose, high level programming language.
  • (^) It was created by Guido van Rossum in 1991 and further developed by the Python Software Foundation.
  • (^) It was designed with an emphasis on code readability, and its syntax allows programmers to express their concepts in fewer lines of code.
  • (^) There are two major Python versions: Python 2 and Python 3. Latest Python 3 Release - Python 3.11. Python 3.10.10 - Feb. 8, 2023 Stable

Prerequisites: Knowledge of any programming language Reason for increasing popularity:

  • (^) Emphasis on code readability, shorter codes, ease of writing
  • (^) Programmers can express logical concepts in fewer lines of code in comparison to languages such as C++ or Java.
  • (^) Python supports multiple programming paradigms, like object- oriented, imperative and functional programming or procedural.
  • (^) There exists inbuilt functions for almost all of the frequently used concepts.
  • (^) Philosophy is “Simplicity is the best”.

Java Code public class HelloWorld { public static void main (String[] args) { System.out.println("Hello, world!"); } } Python Code print("Hello, world!")

Installing Python in Windows, Linux

and Osx (Apple MacIntosh operating system)

  • (^) Python can be installed on Windows, Linux, Mac OS.
  • (^) To install Python on your local machine, get a copy of the standard distribution of Python software from https://www.python.org/downloads based on your operating system, hardware architecture and version of your local machine.

Install Python on Linux Most of Linux distributions come with Python already installed. However, the Python 2.x version is incorporated in many of them. To check if Python 3.x is available, run the following command in the Linux terminal: $ which python If available, it will return the path to the Python3 executable as /usr/local/bin/python3. To install Python on Ubuntu 18.04, Ubuntu 20.04 and above, execute the following commands: $ sudo apt-get update $ sudo apt-get install python3.7 python3-pip After the installation, you can run Python 3.8 and pip3 commands.

Where to use Python

Data Science Python experienced a recent emergence in popularity charts, mainly because of its Data science libraries. A huge amount of data is being generated today by web applications, mobile applications, and other devices. Companies need business insights from this data. Today Python has become the language of choice for data scientists. Python libraries like NumPy, Pandas, and Matplotlib are extensively used in the process of data analysis, including the collection, processing and cleansing of data sets, applying mathematical algorithms, and generating visualizations for the benefit of users. Commercial and community Python distributions by third-parties such as Anaconda and ActiveState provide all the essential libraries required for data science. Machine Learning This is another key application area of Python. Python libraries such as Scikit-learn, Tensorflow and NLTK are widely used for the prediction of trends like customer satisfaction, projected values of stocks, etc. Some of the real-world applications of machine learning include medical diagnosis, statistical arbitrage, basket analysis, sales prediction, etc.

Web Development This is another application area in which Python is becoming popular. Web application framework libraries like django, Pyramid, Flask, etc. make it very easy to develop and deploy simple as well as complex web applications. These frameworks are used extensively by various IT companies. Image Processing The OpenCV library is commonly used for face detection and gesture recognition. OpenCV is a C++ library but has been ported to Python. Because of the rapid development of this feature, Python is a very popular choice from image processing.

Using Interactive Shell: Shell/REPL

Python is an interpreter language. It means it executes the code line by line. Python provides a Python Shell, which is used to execute a single Python command and display the result. It is also known as REPL (Read, Evaluate, Print, Loop), where it reads the command, evaluates the command, prints the result, and loop it back to read the command again. To run the Python Shell, open the command prompt or power shell on Windows and terminal window on mac, write python and press enter. A Python Prompt comprising of three greater-than symbols >>> appears, as shown below.

  • (^) Now, you can enter a single statement and get the result. For example, enter a simple expression like 3 * 2, press enter and it will display the result in the next line, as shown above.