Module 1

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 13

Program: BBA I Semester

SEC-102: Introduction to Python Programming

Module 1

Somesh Sharma
Assistant Professor
Department of Computer Science
Definition and History of Python
• Definition: Python is a high-level, interpreted programming
language known for its readability and simplicity. It's
widely used for both small scripts and large, complex
applications.
• History: Created by Guido van Rossum in the late 1980s,
with its first release in 1991. Python has since evolved into
one of the most popular programming languages due to its
versatility, large community, and extensive libraries.
Significance in Modern Programming
• Readability and Simplicity: Python’s syntax emphasizes
readability, making it an excellent language for beginners
and experts alike.
• Versatility: It supports multiple paradigms, including
object-oriented, procedural, and functional programming.
• Community and Libraries: Python's vast libraries (NumPy,
Pandas, Django, etc.) and strong community support make it
a valuable tool for a wide range of applications.
Overview of Python Applications
• Web Development: Frameworks like Django and Flask
enable Python to build robust web applications.
• Data Science: Libraries like Pandas, NumPy, and Matplotlib
make Python a go-to language for data manipulation and
visualization.
• Automation: Python is often used for automating repetitive
tasks, scripting, and batch processing.
• Other Domains: Includes fields like artificial intelligence,
machine learning, game development, and more.
Installing Python
• Anaconda: A distribution that includes Python, Jupyter
Notebook, and essential libraries for data science and
machine learning. Great for beginners and professionals.
• Standard Python: Installation from the official Python
website allows custom setups and package installations as
needed.
Understanding Python IDEs
• Jupyter Notebook: An interactive environment, primarily
used in data science, that allows code execution in chunks
with inline visualization.
• VS Code: A lightweight, versatile editor that supports
extensions for Python, debugging, and version control.
• PyCharm: A powerful IDE designed specifically for Python,
with features like intelligent code completion, debugging,
and testing support.
Writing the First Python Program
•Using the print() Function: The print() function outputs text
to the console, making it the starting point for interaction in
Python programs.

•Basic Arithmetic Operations: Python supports standard


arithmetic operations (addition +, subtraction -, multiplication
*, division /) to perform calculations.
Step-by-Step Guide to Installing Python through
PyCharm
1. Download and Install PyCharm
• Go to the PyCharm download page.
• Choose the Community edition (free) for most Python
development needs.
• Download and run the installer for your operating system
(Windows, macOS, or Linux).
• Follow the installation instructions (it’s mostly just clicking
through prompts).
2. Install Python (if not already installed)
• If Python is not installed on your system, PyCharm will prompt
you to install it during the setup.
• Alternatively, you can download and install Python from the
official website:
• Visit https://www.python.org/downloads/.
• Download the latest version for your OS.
• Important: During installation, make sure to check the box
"Add Python to PATH" to make sure it works from the
command line.
3. Open PyCharm and Configure Python Interpreter
•After PyCharm is installed, open it.
•You’ll see the Welcome to PyCharm screen. Click "Create New Project".
•In the project setup window:
•Location: Choose a directory for your project.
•Python Interpreter: Click the gear icon next to the Python interpreter field.
•Select Add Interpreter.
•In the pop-up, you can choose either to use a system interpreter (if Python is alread
installed) or a virtual environment (recommended for each project).
•If you don’t see Python in the list, click System Interpreter and navigate to where
Python is installed (e.g., C:\Python\Python39 on Windows).
•Click OK to apply the interpreter settings.
4. Create a New Python File
•Once the project is created, right-click on the project
folder in the left panel and choose New > Python File.
•Name your file (e.g., hello_world.py).
5. Write and Run Your First Python Program
•In the new Python file, type:
python
print("Hello, PyCharm!")
•To run the program, click the Run button (green triangle) at
the top right or use the shortcut Shift + F10.
6. Verifying Installation
• PyCharm should automatically recognize Python and display
the output of your program in the Run window at the bottom.
# Displaying a welcome message
print("Hello, welcome to Python programming!")

# Basic arithmetic operations


print("Addition: 2 + 3 =", 2 + 3)
print("Subtraction: 5 - 2 =", 5 - 2)
print("Multiplication: 4 * 3 =", 4 * 3)
print("Division: 10 / 2 =", 10 / 2)

# Simple message using a variable


language = "Python"
print("This program is written in", language)

You might also like