Unit-3 Web and Internet Technology
Unit-3 Web and Internet Technology
1. Web Development
● Python frameworks such as Django, Flask, and FastAPI help in creating secure and
scalable web applications.
● Popular for building websites, content management systems, and online services.
● Libraries like Pandas, NumPy, Matplotlib, and Seaborn are used for analyzing and
visualizing large datasets.
● Python is used to write scripts for network scanning, vulnerability assessment, and
penetration testing.
● Tools such as Scapy, Paramiko, and Pyshark support network packet analysis and
SSH automation.
○ System backups
○ Log analysis
5. Database Management
● Python is widely used in cloud environments like AWS, Azure, and Google Cloud.
● Helps in writing infrastructure as code using tools like Terraform, Ansible, and Boto3.
● Libraries like Scikit-learn, TensorFlow, and Keras make Python a key tool for
implementing ML and AI.
● Used in IT systems for predictive analytics, customer support bots, and intelligent
automation.
● Python toolkits such as Tkinter, PyQt, and Kivy help in creating cross-platform desktop
apps.
● Used to build internal tools, GUIs for system control, and simple management software.
Python is a high-level, interpreted programming language created by Guido van Rossum and
released in 1991. It is known for its simple syntax and readability, making it ideal for beginners
and professionals alike. Python is widely used in various domains such as web development,
data analysis, artificial intelligence, automation, and more.
Applications of Python:
● Data science and machine learning with libraries like Pandas, NumPy, and Scikit-learn
Example Code:
print("Hello, world!")
Python’s simplicity and flexibility have made it one of the most popular programming languages
in the world today.
Functions in Python:
A function is a block of reusable code that performs a specific task. Functions help in organizing
code, reducing repetition, and improving readability.
Types of Functions:
2. User-defined functions: Created by the programmer using the def keyword
Syntax of a Function:
def function_name(parameters):
# code block
return value
Example:
def greet(name):
return "Hello, " + name
print(greet("Vishal"))
Function Parameters:
● Positional arguments
● Keyword arguments
● Default arguments
Scoping in Python:
Scoping defines the visibility and lifetime of variables within different parts of a program.
Types of Scope:
1. Local Scope: Variables declared inside a function, accessible only within that function.
2. Global Scope: Variables declared outside all functions, accessible throughout the
program.
3. Enclosing Scope (Nonlocal): In nested functions, the outer function’s variables are in
an enclosing scope.
4. Built-in Scope: Reserved names in Python like len, print, etc.
LEGB Rule:
Example:
x = "global"
def outer():
x = "enclosing"
def inner():
x = "local"
print(x)
inner()
Functions and scoping are essential concepts that help structure programs and manage
variable visibility effectively.
Recursion:
Recursion is a programming technique where a function calls itself to solve a smaller part of the
problem. It is commonly used for problems that can be broken down into similar sub-problems.
Key Characteristics:
Example:
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)
print(factorial(5)) # Output: 120
Note: Recursive functions should always have a base case to avoid infinite recursion.
Global Variables:
A global variable is a variable declared outside of all functions. It is accessible throughout the
program, including inside functions (if declared properly).
Example:
x = 10
def modify():
global x
x=x+5
modify()
print(x) # Output: 15
Important Points:
● Global variables can be accessed inside functions without declaring them as global.
● Overusing global variables is not recommended as it makes the code harder to debug
and maintain.
Topic: Creation
In Python, “creation” typically refers to the process of creating different types of objects,
such as variables, data structures, functions, and classes. Python allows dynamic and flexible
creation of these components.
1. Variable Creation:
Example:
x = 10
name = "Python"
2. List Creation:
Example:
3. Function Creation:
Example:
def greet():
print("Hello")
4. Class Creation:
Classes are created using the class keyword and are used in object-oriented programming.
Example:
class Person:
def __init__(self, name):
self.name = name
5. File Creation:
Files can be created using the open() function with "w" or "x" mode.
Example:
Summary:
Python supports the creation of a wide range of objects—from simple variables to complex
classes and files—using straightforward syntax, making it ideal for rapid development and
prototyping.
1. Strings
Strings are immutable in Python. This means you cannot insert or delete characters directly
in an existing string. You must create a new string.
s = "Hello"
s = s[:2] + "y" + s[2:] # Output: "Heyllo"
s = "Hello"
s = s[:1] + s[2:] # Output: "Hllo"
2. Tuples
Tuples are also immutable. You cannot directly insert or delete items in a tuple. You must
convert it to a list first.
t = (1, 2, 3)
t = list(t)
t.insert(1, 5)
t = tuple(t) # Output: (1, 5, 2, 3)
t = (1, 2, 3)
t = list(t)
del t[1]
t = tuple(t) # Output: (1, 3)
3. Lists
Insertion:
lst = [1, 2, 3]
lst.append(4) # At end: [1, 2, 3, 4]
lst.insert(1, 5) # At index 1: [1, 5, 2, 3, 4]
Deletion:
4. Dictionaries
Dictionaries are mutable and support insertion and deletion using keys.
Insertion:
d = {"a": 1, "b": 2}
d["c"] = 3 # {'a': 1, 'b': 2, 'c': 3}
Deletion:
Summary:
● Strings & Tuples: Immutable – cannot directly insert or delete; use slicing or convert to
a list.
● Lists & Dictionaries: Mutable – allow direct insertion and deletion using methods like
append(), insert(), remove(), pop(), and del