Professional Documents
Culture Documents
History of Python
Python is a widely used general-purpose, high-level programming language. It was initially
designed by Guido van Rossum in 1991 and developed by Python Software Foundation. It was
mainly developed for emphasis on code readability, and its syntax allows programmers to express
concepts in fewer lines of code.
In the late 1980s, history was about to be written. It was that time when working on Python started.
Soon after that, Guido Van Rossum began doing its application-based work in December of 1989
at Centrum Wiskunde & Informatica (CWI) which is situated in the Netherlands. It was started
firstly as a hobby project because he was looking for an interesting project to keep him occupied
during Christmas. The programming language in which Python is said to have succeeded is ABC
Programming Language, which had interfacing with the Amoeba Operating System and had the
feature of exception handling. He had already helped to create ABC earlier in his career and he
had seen some issues with ABC but liked most of the features. After that what he did was really
very clever. He had taken the syntax of ABC, and some of its good features. It came with a lot of
complaints too, so he fixed those issues completely and had created a good scripting language that
had removed all the flaws. The inspiration for the name came from BBC’s TV Show – ‘Monty
Python’s Flying Circus’, as he was a big fan of the TV show and also, he wanted a short, unique
and slightly mysterious name for his invention and hence he named it Python.
Versions of Python
Version Release Date Important Features
Python 0.9.0 February 1991 • Classes with inheritance exception
handling
• Functions
• Modules
Python 3.9 - Current October 2020 • Dictionary Merge & Update Operators
Version • New removeprefix() and removesuffix()
string methods
• Builtin Generic Types
Compilers of python:
Online Python Compiler:
Advantages:
1. Accessibility: Online Python compilers can be accessed from any device with an internet
connection, making it convenient for users who don't have Python installed locally or need to code
on the go.
2. No installation required: Users don't need to install Python or any related libraries on their local
machine, which reduces setup time and potential conflicts between different versions of Python.
3. Collaboration: Online compilers often allow users to share code snippets easily, making it
convenient for collaboration and troubleshooting.
Disadvantages:
1. Internet dependency: Online compilers require an internet connection to function. If the internet
is slow or unavailable, it can hinder the development process.
2. Privacy concerns: Some online compilers may store code snippets temporarily, potentially
raising concerns about data privacy and security.
3. Limited resources: Online compilers may have limitations on execution time, memory usage, or
access to certain Python modules or libraries, which could be restrictive for complex projects.
Disadvantages:
1. Installation and setup: Users need to install Python and any necessary libraries on their local
machine, which might require some technical knowledge and time.
2. Platform compatibility: An offline compiler may have issues running on different operating
systems, potentially leading to compatibility problems.
3. Collaboration challenges: Sharing code from an offline compiler might involve manually
sharing files, which can be less efficient than the collaborative features of online compilers.
In summary, choosing between an online and offline Python compiler depends on your specific
needs and circumstances. If you prioritize accessibility, collaboration, and don't want to deal with
1. Offline Compilers:
PyDev
Eclipse is an IDE best for Java language. Still, thanks to a system of extensions and plugins. We
can use more languages to compile and run in Eclipse itself. PyDev is also one of the plugins that
Eclipse can use as a Python IDE.
There are some interesting features to know about PyDev:
• It provides good support for Python Web Development.
• It has a good syntax highlighting and remote debugger.
• It also has an interactive console.
• It is easy to learn and has several features like CPython and Jython.
• It offers error phasing and folding of codes that are useful for devs.
PyCharm
PyCharm is one of the best python compilers as it is used by most professional python developers.
PyCharm is developed by JetBrains. It gives a variety of tools, modules, and packages to speed up
Python development.
Some features of PyCharm include:
• It offers more than 1000 plugins.
• PyCharm supports smart code navigation.
• You can increase productivity by using the customizable interface feature.
• It has a fast and safe refactoring tool.
• It offers Live Code Verification along with Syntax Highlighting.
Jupyter Notebook
Jupyter Notebook is an IDE mostly used for Data Science environments in python. It is developed
by Fernando Pérez and Brian Granger. It is a free IDE, so everyone can use it while compiling any
python codes.
The most notable features of the Jupyter Notebook are:
• It allows you to use data visualization tools like Numpy, Seaborn, and Matplotlib.
• User can export the task in multiple formats such as CSV, pdf, Html, etc.
Atom
Atom is also one of the best python compilers that are flexible and easy to use. It is developed by
GitHub. Also, you can use Atom on different platforms like Windows, Linux, and macOS.
Let's now discuss some of its features:
• Users can install and manage packages on their own.
• It also gives you the git integration.
• It supports a large number of plugins.
• You can give custom commands to the compiler for better interaction.
• Smart auto-completion.
Spyder
Spyder is another python IDE that is free and easy to use. It is developed by Pierre Raybaut. It
supports multiple platforms like Windows, Linux, and Mac. Let's discuss some features of Spyder.
• Users can explore and edit the variables using GUI.
• Users can view any object documents instantly and modify the document.
• It has a strong debugger.
• It improves the coding experience by giving a variety of options in plugins.
• It has quality community support.
IDLE
IDLE is a highly regarded and advised IDE for educational purposes because of its simplicity. As
earlier said, IDLE is a very simple and powerful IDE designed mainly for beginners.
Some of the exciting features to know about IDLE:
• This IDE is suitable for developers at the beginning level.
• The capacity to look for multiple files.
• An interactive interpreter that highlights syntax and shows error and I/O messages.
• Along with regular text editor features and smart indenting.
• An extremely capable debugger.
Vim
An open-source and free text and source code editor is called Vim. It comes with inbuilt Git
Control. You have to install Vim in Windows, but for UNIX and macOS, it is already installed.
There is a big list of plugins in Vim.
Let's know about the Features of Vim:
• It has a powerful search engine.
• It supports many different plugins.
• Lightweight app.
• It is very stable while running code.
• Cross-platform development assistance.
Visual Studio Code
Microsoft made the source-code editor Visual Studio Code. It is also known as VS Code. VS Code
is supported in Windows, Linux, and macOS using the Electron Framework. The features are
debugging help, syntax highlighting, smart code completion, snippets, code refactoring, and
integrated Git.
Essential Features of VS Code:
• With its robust command line interface, Visual Studio Code gives you complete control
over how the editor opens.
• Git integration is inbuilt into Visual Studio Code. This allows you to push, pull, and commit
changes to your code to a remote Git repository.
• With all UI except the editor hidden in VSCode's Zen Mode, you can concentrate on writing
code.
2. Online Compilers
Programiz
Programiz provides a free Python online compiler and interpreter that allows users to write,
compile, and execute Python code directly from their web browser. It provides a clean UI which
will help you execute your basic python codes.
TutorialsPoint
Tutorialspoint Python compiler is a simple yet powerful tool that supports Python 2 and Python 3.
It has a clean and intuitive interface, making it easy to use even for beginners. The compiler also
provides features like syntax highlighting, auto-indentation, and code completion, which can help
streamline the coding process.
Scalar
Scalar is a web-based code editor that supports several programming languages, including Python.
It provides a real-time compiler and debugger and allows you to collaborate with others.
Replit
Replit is an online platform that serves as a compiler, IDE, interpreter, and editor. It enables users
to write code, run, share, collaborate, and execute Python through your browser.
Replit Features
• GitHub integration
• Support for 50+ programming languages
• Use it from any computer that is connected to the internet and can and run a web browser
• Collaborate with your friends in real-time with the Multiplayer feature
• Collaborate with your coworkers with the Teams feature
• Use Replit on any operating system including macOS, Windows, and Linux
• Quickly start your projects with the Hosting feature
Python.org
Python.org is Python’s official website. It has an online Python shell provided
by PythonAnyWhere. You can execute the Python code in the interactive shell. You will get access
to machines with a full Python environment already installed and develop or execute code directly
from your browser without installing software.
w3school
W3Schools is a popular online learning platform that offers a web-based IDE for Python
programming. It provides a simple interface and allows you to write and test your Python code
online.
Jdoodle
JDoodle is another popular online code editor and compiler that supports several programming
languages, including Python. It has a clean and easy-to-use interface and provides a real-time
compiler and debugger.
2. Select Windows
Figure: 2 Tree
Here we have been given a tree which is containing 10 node from A to J. We have to implement
BFS (Breadth First Search), DFS(Depth Limit Search), DLS(Depth Limit Search).
Here the goal node is J and we have to implement above search algorithm to traverse the tree and
find the goal node.
1. Create a Node class that has three attributes: left, right, and val. The left and right attributes
represent the left and right child nodes of the current node, while the val attribute represents
the value stored in the current node.
2. Define a function called preorder that takes two arguments: root and element. The root
argument represents the root node of the binary tree, while the element argument represents
the value to search for in the tree.
3. In the preorder function, check if the root argument is not None. If it is not, then:
i) Check if the value of the current node (root.val) is equal to the value of the element
argument. If it is, then print 'true'.
ii) Recursively call the preorder function with the left child node (root.left) and the
element argument as arguments.
iii) Recursively call the preorder function with the right child node (root.right) and the
element argument as arguments.
4. Create an instance of the Node class with a value of 1 and assign it to a variable called root.
5. Set the left child node of root to a new instance of the Node class with a value of 2.
6. Set the right child node of root to a new instance of the Node class with a value of 3.
7. Set the left child node of the left child node of root to a new instance of the Node class with
a value of 4.
8. Set the right child node of the left child node of root to a new instance of the Node class
with a value of 5.
5. Now we search in the same depth limit and move along depth-wise to check for the goal
nodes.
6. If depth limit is found to be reached, then we retrace back to nearest nodes that remain
unvisited or unexplored.
7. Then we push them into the stack and mark them visited.
8. We continue to perform these steps in iterative ways unless the goal node is reached or
until all nodes within depth limit have been explored for the goal.
Step 2: POP top node A and find its neighbours node i.e. B,C,D.
Step 3: Now node B is on top. So POP B and find its neighbour nodes. i.e. G, H.
Step 4: Now node G is on top. So POP G and we reached limit 2 so we will not check its neighbour
node.
Step 5: Now node H is on top. So POP H and we reached limit 2 so we will not check its neighbour
node.
Step 6: Now node D is on top. So POP D and find its neighbour nodes. i.e. E, F.
Step 7: Now node F is on top. So POP F and we reached limit 2 so we will not check its neighbour
node.
Step 8: Now node E is on top. So POP E and we reached limit 2 so we will not check its neighbour
node.
Step 10: Now the stack is empty and we have not found goal node so we return false.
2. Tiles can be moved either horizontally or vertically, but only one position at a time.
3. The objective is to reach the goal state from an initial state using the fewest possible moves.
Solving the 8-puzzle problem is often done using search algorithms like A* search or breadth-first
search. Here's a simplified outline of how you can approach solving it using A* search:
1. State Representation: Represent the puzzle's state as a data structure. Typically, this involves a
2D array to represent the tile positions.
2. Define the Heuristic: Choose a heuristic function to estimate how close a state is to the goal state.
Common heuristics include the Manhattan distance (sum of distances each tile is away from its
goal position) and the misplaced tiles count (number of tiles not in their goal positions).
3. Initial State: Start with the initial state of the puzzle.
The route taken by the aforementioned algorithm to arrive at the final configuration of the 8-Puzzle
from the starting configuration supplied is shown in the diagram below. Keep in mind that only
nodes with the lowest costs function value are extended.
if n == 1:
TowerOfHanoi(n-1, source, destination, auxiliary) // Move n-1 disks from source to auxiliary
Move disk from source to destination // Move the largest disk from source to destination
TowerOfHanoi(n-1, auxiliary, source, destination) // Move n-1 disks from auxiliary to destination
The traveling salesman problems abide by a salesman and a set of cities. The salesman has to visit
every one of the cities starting from a certain one (e.g., the hometown) and to return to the same
city. The challenge of the problem is that the traveling salesman needs to minimize the total length
of the trip.Suppose the cities are x1 x2 xn where cost cij denotes the cost of travelling from city
xi to xj. The travelling salesperson problem is to find a route starting and ending at x1 that will take
in all cities with the minimum cost.
Algorithm-
• Travelling salesman problem takes a graph G {V, E} as an input and declare another graph
as the output (say G’) which will record the path the salesman is going to take from one
node to another.
• The algorithm begins by sorting all the edges in the input graph G from the least distance
to the largest distance.
• The first edge selected is the edge with least distance, and one of the two vertices (say A
and B) being the origin node (say A).
• Then among the adjacent edges of the node other than the origin node (B), find the least
cost edge and add it onto the output graph.
• Continue the process with further nodes making sure there are no cycles in the output graph
and the path reaches back to the origin node A.
• If the origin is mentioned in the given problem, then the solution must always start from
that node only.
Algorithm:
The Eight Queens Problem can be solved using a backtracking algorithm, which systematically explores
different combinations of queen placements while ensuring that no two queens threaten each other. Here's
an in-depth algorithm for solving the Eight Queens Problem:
Algorithm: Backtracking for the Eight Queens Problem
1. Initialize the Chessboard: Create an 8x8 chessboard (represented as a 2D array) and initialize all cells to
empty (0) to represent an empty board.
2. Place Queens (Recursive Function): Define a recursive function, let's call it place Queens(board, row),
where board represents the current state of the chessboard, and row is the current row being considered.
Recursive Case
For the current row, iterate through each column (from 0 to 7).
• For each column, check if it's safe to place a queen in that cell.
• To check safety, ensure that:
• There is no queen in the same column in any of the previous rows.
• There are no queens on the diagonals (both left and right) in any of the previous rows.
• If it's safe to place a queen in the current cell, mark the cell as a queen (e.g., set it to 1) and move to
the next row by calling placeQueens(board, row + 1) recursively.
• After the recursive call, if it doesn't lead to a valid solution, backtrack by removing the queen from
the current cell (set it back to 0), and continue checking the next column.
• Continue this process recursively for all rows.
3. Start the Algorithm: Call placeQueens(board, 0) to start the algorithm from the first row.
4. Print Solutions: In the placeQueens function, when a valid solution is found (all queens are placed without
conflicts), print the chessboard with queens as the solution.
5. End of Algorithm: The algorithm will continue to explore and backtrack until all possible solutions are
found or exhausted.2. Place Queens (Recursive Function): Define a recursive function, let's call it
placeQueens(board, row), where board represents the current state of the chessboard, and row is the current
row being considered.
A20405220040
Nitin Kumar
Nitin Kumar
Output:
B. Lisp Platform:
● The problems that were faced by the traditional programming languages that lead to the
evolution of Lisp.
Traditional programming languages faced problems like limited flexibility and expressiveness,
which led to the evolution of Lisp. Lisp addressed these issues by introducing a highly flexible
and symbolic approach to programming, making it easier to manipulate code and data.
2. MacLisp (1966): Developed at MIT, it introduced significant features like the EVAL function.
3. InterLisp (circa 1967): Focused on interactive programming and was used on early personal computers.
4. Scheme (1975): A minimalist dialect emphasizing simplicity and elegance. It influenced the design of other
languages, including Common Lisp.
5. Common Lisp (1984): A standardized version of Lisp that aimed to unify various Lisp dialects. Common Lisp
introduced many features and remains a widely used Lisp dialect.
6. Emacs Lisp: A dialect of Lisp used for extending the Emacs text editor.
Nitin Kumar A20405220040
7. Clojure (2007): A modern Lisp dialect that runs on the Java Virtual Machine (JVM) and emphasizes functional
programming and immutability.
9. AutoLisp: A dialect of Lisp used for extending AutoCAD, a popular computer-aided design software.
10. Dylan (circa 1992): A dynamically typed, multi-paradigm language with Lisp roots.
11. NewLISP: A scripting language and dialect of Lisp designed for practical use and ease of integration.
12. Picolisp: A minimalistic and lightweight Lisp dialect with a unique data structure called "Pilog" for representing
facts.
The problem domain of AI lab and the library which will be used and their distribution.
The problem domain of an AI lab encompasses the study and development of artificial intelligence
(AI) technologies and applications. It involves creating algorithms, models, and systems that mimic
human intelligence and behavior, enabling computers to perform tasks that typically require
human cognitive abilities. AI labs focus on areas such as:
● Face recognition
● Speech recognition
● Solving Complex Problems
● Training Future AI Experts
● Collaboration and Networking
1. ASDF: A build system for Common Lisp, essential for managing dependencies.
2. Quicklisp: A package manager for Common Lisp, simplifying library installation and management.
8. CLIM: The Common Lisp Interface Manager for building graphical user interfaces.
9. CLOS MOP: The Meta-Object Protocol for extending and customizing the Common Lisp Object System (CLOS).
10. LTK: A Common Lisp binding to the Tk graphical toolkit for creating cross-platform GUI applications.
11. Numpy and SciPy for Lisp (Lisp-Stat): Libraries for scientific computing and data analysis in Common Lisp.
12. LASS: A library for handling sound and audio in Common Lisp.
14. SBCL Foreign Function Interface (FFI): Allows interfacing with C libraries from Common Lisp.
15. Inferior Shell: Provides a way to interact with external shell processes from within Common Lisp.
These are just a few examples, and there are many more libraries and packages available to
extend the functionality of Lisp for various domains and applications. The availability of libraries
is one of the strengths of Lisp, contributing to its versatility and suitability for a wide range of
tasks.
Lisp is available on three platforms, all of them require 5-50MB disk space for installation:
● Windows
● Linux
● MacOS
Conclusion: Emacs with SLIME is preferred for Lisp due to its powerful features, interactive
REPL, debugging support, extensive extensions, and strong community, making it a versatile and
efficient development environment.
1. repl.it:
- Website: [repl.it](https://repl.it)
- Features: It provides a code editor, a REPL (Read-Eval-Print Loop) environment, and the ability to create and run
Lisp programs directly in your web browser. You can share your code and collaborate with others.
Conclusion: Choosing repl.it for online Lisp coding is smart. It's user-friendly, supports multiple
Lisp dialects, offers collaboration, version control, and has an active community, making it ideal
for learning and development from any web-enabled device.
4. Install SLIME:
● Launch Emacs.
● Open the Emacs configuration file, usually named .emacs or init.el. You can find it in your home directory.
● Add the following lines to your Emacs configuration file to install and configure SLIME for your preferred
Lisp implementation (e.g., SBCL):
Nitin Kumar A20405220040
Fig 1.5: Installation of Slime
5. Using SLIME: To start using SLIME, open a Lisp source file (e.g., with a .lisp extension) or create a new
one. Then, run M-x slime (Alt + x, type "slime," and press Enter). SLIME will start, and you can use it to interact
with your chosen Lisp implementation.
D. Python
E. Lisp
F. Prolog
C. Prolog Platform:
⚫ The problems that were faced by the traditional programming languages that lead to the
evolution of prolog.
Prolog (Programming in Logic) is a declarative programming language that was developed
in the 1970s, and it evolved as a response to the limitations and challenges faced by
traditional imperative programming languages. Here are some of the problems with traditional
programming languages that led to the development and evolution of Prolog:
1. Lack of Declarative Semantics: Traditional programming languages, like C, Java, and Pascal, are imperative and
require programmers to specify how to achieve a particular task step by step. This can make code hard to read,
understand, and maintain. Prolog, on the other hand, offers a declarative approach, where you specify what you
want to achieve, and the system figures out how to do it. This makes Prolog particularly well-suited for tasks
involving complex logical relationships.
2. Inefficiency in Symbolic Reasoning: Traditional languages are not well-suited for symbolic reasoning and complex
rule-based systems. They require extensive programming to handle symbolic manipulation and rule-based
inference. Prolog, with its built-in support for symbolic reasoning, makes it easier to work with knowledge
representation and rule-based systems.
3. Limited Pattern Matching: Pattern matching is a fundamental aspect of many applications, such as text processing
and artificial intelligence. Traditional languages often lack powerful built-in pattern matching capabilities, making it
harder to work with data matching specific patterns. Prolog excels at pattern matching, making it an excellent choice
for tasks like natural language processing and expert systems.
4. Explicit Data Manipulation: Traditional languages require explicit data manipulation, which can be tedious and
error-prone. Prolog, on the other hand, uses unification and pattern matching to handle data manipulation
implicitly, simplifying the code and reducing the chance of errors.
5. Procedural Complexity: Traditional languages often lead to complex and lengthy code due to their procedural
nature. Prolog's declarative nature allows for more concise code, making it easier to express complex relationships
and logic in a compact manner.
6. Difficulties in Handling Uncertainty: Many real-world problems involve uncertainty and incomplete information.
Traditional languages struggle to handle these issues effectively. Prolog, with its ability to represent and reason with
uncertain information through probabilistic and fuzzy logic extensions, is better equipped to address such problems.
• Evolution of Prolog:
The programming language, Prolog, was born of a project aimed not at producing a
programm3ing language but at processing natural languages; in this case, French. The project
gave rise to a preliminary version of Prolog at the end of 1971 and a more definitive version at
the end of 1972.
Year Milestone
Birth of Prolog - Alain Colmerauer and Robert Kowalski laid the foundation for Prolog
1972 with the development of the first Prolog system at the University of Aix-Marseille.
Edinburgh Prolog - David H. D. Warren developed the Warren Abstract Machine (WAM)
1980 and Edinburgh Prolog, making Prolog more efficient and widely adopted.
ISO Standardization - The first official Prolog standard, Edinburgh Prolog, was proposed
1981 as an international standard, but it wasn't accepted.
1982 C-Prolog - Quintus Prolog, one of the first commercially available Prolog systems, was
developed by SRI International.
1987 ISO Prolog Standard - The International Organization for Standardization (ISO) released
the official standard for Prolog, known as ISO Prolog.
Integration with Other Languages - Prolog saw integration with other languages and
2010s tools, enabling hybrid systems and more extensive applications.
Future Expanding Use Cases - Prolog is being explored for new applications, including natural
language processing, data analysis, and rule-based systems.
The problem domain of AI lab and the library which will be used and their distribution.
The problem domain of an AI lab encompasses the study and development of artificial intelligence
(AI) technologies and applications. It involves creating algorithms, models, and systems that mimic
human intelligence and behavior, enabling computers to perform tasks that typically require
human cognitive abilities. AI labs focus on areas such as
• Face recognition
• Speech recognition
• Solving Complex Problems
• Training Future AI Experts
• Collaboration and Networking
2. Repl.it: Repl.it is an online platform that supports various programming languages, including Prolog. It provides
an online code editor, compiler/interpreter, and collaborative coding features. You can write and run Prolog code in
your browser on Repl.it at Repl.it Prolog.
3. Ideone: Ideone is an online compiler and debugging tool that supports Prolog. You can write Prolog code in the
online editor and run it to see the output. It's available at Ideone Prolog.
4. OnlineGDB: OnlineGDB is an online IDE and debugger that supports Prolog. You can write, run, and debug
Prolog code within your web browser. It's accessible at OnlineGDB Prolog.
5. TutorialsPoint: TutorialsPoint offers an online Prolog compiler and editor that allows you to write and execute
Prolog code. You can access it at TutorialsPoint Prolog.
Step 11:The last screen is of choosing components, all components are already marked so don’t
change anything just click on Install button.
Step 12: After this installation process will start and will hardly take a minute to complete the
installation.
Step 13: Click on Finish after the installation process is complete.
Step 14: SWI Prolog is successfully installed on the system and an icon is created on the desktop.
Step 15: Run the software and see the interface.
Fig 12.1
Algorithm:
Step-1 Define a grid representing the environment with obstacles. 0 represents a passable cell, and 1
represents an obstacle and define directions (up, down, left, right) for movement.
Step-2 Create two separate queues for the start and end searches, respectively and create two sets for
tracking visited nodes in the start and end searches.
Step-3 Now add the start node to and the end node .While both queue_start and queue_end have nodes.Pop
a node from both queue_start and queue_end If current_start is equal to current_end, or current_start is in
visited_end .
Return True
Step-4 For each direction in directions, check neighboring nodes Ensure the neighboring node is within the
grid boundaries.Ensure the neighboring node is not an obstacle.
Step-5 If conditions are met, add the neighboring node to the appropriate queue .
Nitin Kumar A20405220040
Step-6 If the loop completes without finding a meeting point, return False .
Output: