0% found this document useful (0 votes)
15 views43 pages

Unit_1

The document provides an introduction to Python programming, covering fundamental concepts such as data types, string operations, lists, tuples, sets, and dictionaries. It explains string manipulation techniques, list methods, and the characteristics of tuples and sets, including their properties and how to perform various operations on them. The content is structured to facilitate understanding of Python's capabilities for handling different data structures.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views43 pages

Unit_1

The document provides an introduction to Python programming, covering fundamental concepts such as data types, string operations, lists, tuples, sets, and dictionaries. It explains string manipulation techniques, list methods, and the characteristics of tuples and sets, including their properties and how to perform various operations on them. The content is structured to facilitate understanding of Python's capabilities for handling different data structures.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 43

Unit-1

Introduction to Python, Types, Expressions & Variables, String Operations, Lists & Tuples, Sets,
Dictionaries, Conditions & Branching, Loops, Functions, Objects & Classes

String Operations

Looping Through a String Since strings are arrays, we can loop through the characters in a string,
with a for loop.

for x in "banana":
print(x,end=' ')

b a n a n a

str="ranjith"

print(len(str))
txt = "The best things in life are free!"
if "free" in txt:
print("Yes, 'free' is present.")

txt = "The best things in life are free!"


print("expensive" not in txt)

7
Yes, 'free' is present.
True

Slicing

You can return a range of characters by using the slice syntax.Specify the start index and the end
index, separated by a colon, to return a part of the string.

b = "Hello, World!"
print(b[2:5])
#slice from start
print(b[:3])
#slice to end
print(b[2:])
#Negative Indexing
print(b[-5:-2])

llo
Hel
llo, World!
orl

Python - Modify Strings


a = "Hello, World!"
#Upper Case
print(a.upper())
#lower Case
print(a.lower())
#Remove Whitespace
a = " Hello, World! "
print(a)
print(a.strip())
a=a.strip()
#Replace String
print(a.replace('H','J'))
#Split String
print(a.split(", "))

HELLO, WORLD!
hello, world!
Hello, World!
Hello, World!
Jello, World!
['Hello', 'World!']

Python - String Concatenation

#String Concatenation
a = "Hello"
b = "World"
c = a + b
print(c)

Python - Format - Strings

#String Format
age = 36
# txt = "My name is John, I am " + age ##TypeError: can only
concatenate str (not "int") to str
#F-Strings
txt = f"My name is John, I am {age}"
print(txt)

My name is John, I am 36

Placeholders and Modifiers A placeholder can contain variables, operations, functions, and
modifiers to format the value.

A placeholder can include a modifier to format the value. A modifier is included by adding a
colon : followed by a legal formatting type, like .2f which means fixed point number with 2
decimals:
price = 59
txt = f"The price is {price:.2f} dollars"
print(txt)

The price is 59.00 dollars

Python - Escape Characters

txt = 'It\'s alright.'


print(txt)
txt = "This will insert one \\ (backslash)."
print(txt)
txt = "Hello\nWorld!"
print(txt)
txt = "Hello\rWorld!"
print(txt)
#This example erases one character (backspace):
txt = "Hello \bWorld!"
print(txt)
#A backslash followed by three integers will result in a octal value:
txt = "\110\145\154\154\157"
print(txt)
#A backslash followed by an 'x' and a hex number represents a hex
value:
txt = "\x48\x65\x6c\x6c\x6f"
print(txt)

It's alright.
This will insert one \ (backslash).
Hello
World!
World!
HelloWorld!
Hello
Hello

Python - String Methods


Lists & Tuples

Python Lists

List Items List items are ordered, changeable, and allow duplicate values.

List items are indexed, the first item has index [0], the second item has index [1] etc.

Ordered

When we say that lists are ordered, it means that the items have a defined order, and that order
will not change.

If you add new items to a list, the new items will be placed at the end of the list.

Note: There are some list methods that will change the order, but in general: the order of the
items will not change. Changeable The list is changeable, meaning that we can change, add, and
remove items in a list after it has been created.

Allow Duplicates

Since lists are indexed, lists can have items with the same value:

# The list() Constructor


# It is also possible to use the list() constructor when creating a
new list.
thislist = list(("apple", "banana", "cherry")) # note the double
round-brackets
print(thislist)

['apple', 'banana', 'cherry']

Python - Access List Items


# Access Items
thislist = ["apple", "banana", "cherry"]
print(thislist[1])
# Negative Indexing
thislist = ["apple", "banana", "cherry"]
print(thislist[-1])
# Range of Indexes
thislist = ["apple", "banana", "cherry", "orange", "kiwi", "melon",
"mango"]
print(thislist[2:5])
# This example returns the items from the beginning to, but NOT
including, "kiwi":
thislist = ["apple", "banana", "cherry", "orange", "kiwi", "melon",
"mango"]
print(thislist[:4])
# Check if Item Exists
thislist = ["apple", "banana", "cherry"]
if "apple" in thislist:
print("Yes, 'apple' is in the fruits list")

banana
cherry
['cherry', 'orange', 'kiwi']
['apple', 'banana', 'cherry', 'orange']
Yes, 'apple' is in the fruits list

Python - Change List Items

# Change Item Value


thislist = ["apple", "banana", "cherry"]
thislist[1] = "blackcurrant"
print(thislist)
# Change a Range of Item Values
thislist = ["apple", "banana", "cherry", "orange", "kiwi", "mango"]
thislist[1:3] = ["blackcurrant", "watermelon"]
print(thislist)
# If you insert more items than you replace, the new items will be
inserted where you specified, and the remaining items will move
accordingly:
thislist = ["apple", "banana", "cherry"]
thislist[1:2] = ["blackcurrant", "watermelon"]
print(thislist)
# Insert Items
thislist = ["apple", "banana", "cherry"]
thislist.insert(2, "watermelon")
print(thislist)

['apple', 'blackcurrant', 'cherry']


['apple', 'blackcurrant', 'watermelon', 'orange', 'kiwi', 'mango']
['apple', 'blackcurrant', 'watermelon', 'cherry']
['apple', 'banana', 'watermelon', 'cherry']

Python - Add List Items

# Append Items
thislist = ["apple", "banana", "cherry"]
thislist.append("orange")
print(thislist)
# Insert Items
thislist = ["apple", "banana", "cherry"]
thislist.insert(1, "orange")
print(thislist)
# Extend List
thislist = ["apple", "banana", "cherry"]
tropical = ["mango", "pineapple", "papaya"]
thislist.extend(tropical)
print(thislist)
# Add Any Iterable
thislist = ["apple", "banana", "cherry"]
thistuple = ("kiwi", "orange")
thislist.extend(thistuple)
print(thislist)

['apple', 'banana', 'cherry', 'orange']


['apple', 'orange', 'banana', 'cherry']
['apple', 'banana', 'cherry', 'mango', 'pineapple', 'papaya']
['apple', 'banana', 'cherry', 'kiwi', 'orange']

Python - Remove List Items

# Remove Specified Item


thislist = ["apple", "banana", "cherry"]
thislist.remove("banana")
print(thislist)
# If there are more than one item with the specified value, the
remove() method removes the first occurrence:
thislist = ["apple", "banana", "cherry", "banana", "kiwi"]
thislist.remove("banana")
print(thislist)
# Remove Specified Index
thislist = ["apple", "banana", "cherry"]
thislist.pop(1)
print(thislist)
# The del keyword also removes the specified index:
thislist = ["apple", "banana", "cherry"]
del thislist[0]
print(thislist)
# The del keyword can also delete the list completely.
thislist = ["apple", "banana", "cherry"]
del thislist
# Clear the List
thislist = ["apple", "banana", "cherry"]
thislist.clear()
print(thislist)

['apple', 'cherry']
['apple', 'cherry', 'banana', 'kiwi']
['apple', 'cherry']
['banana', 'cherry']
[]

Python - Loop Lists

# Loop Through a List


thislist = ["apple", "banana", "cherry"]
for x in thislist:
print(x)
# Loop Through the Index Numbers
thislist = ["apple", "banana", "cherry"]
for i in range(len(thislist)):
print(thislist[i])
# Looping Using List Comprehension
thislist = ["apple", "banana", "cherry"]
[print(x) for x in thislist]

apple
banana
cherry
apple
banana
cherry
apple
banana
cherry

[None, None, None]

Python - List Comprehension List comprehension offers a shorter syntax when you want to
create a new list based on the values of an existing list.

Example:

Based on a list of fruits, you want a new list, containing only the fruits with the letter "a" in the
name.

Without list comprehension you will have to write a for statement with a conditional test inside:
fruits = ["apple", "banana", "cherry", "kiwi", "mango"]
newlist = []

for x in fruits:
if "a" in x:
newlist.append(x)

print(newlist)
#with list comprehension
fruits = ["apple", "banana", "cherry", "kiwi", "mango"]

newlist = [x for x in fruits if "a" in x]

print(newlist)
# newlist = [expression for item in iterable if condition == True]
##syntax

['apple', 'banana', 'mango']


['apple', 'banana', 'mango']

Python - Sort Lists

# Sort List Alphanumerically


thislist = ["orange", "mango", "kiwi", "pineapple", "banana"]
thislist.sort()
print(thislist)
# Sort Descending
thislist = ["orange", "mango", "kiwi", "pineapple", "banana"]
thislist.sort(reverse = True)
print(thislist)
# Customize Sort Function
def myfunc(n):
return abs(n - 50)

thislist = [100, 50, 65, 82, 23]


thislist.sort(key = myfunc)
print(thislist)
# Case Insensitive Sort
# by default it was a case sensitive
thislist = ["banana", "Orange", "Kiwi", "cherry"]
thislist.sort()
print(thislist)
# Perform a case-insensitive sort of the list:
thislist = ["banana", "Orange", "Kiwi", "cherry"]
thislist.sort(key = str.lower)
print(thislist)
# Reverse Order
thislist = ["banana", "Orange", "Kiwi", "cherry"]
thislist.reverse()
print(thislist)
['banana', 'kiwi', 'mango', 'orange', 'pineapple']
['pineapple', 'orange', 'mango', 'kiwi', 'banana']
[50, 65, 23, 82, 100]
['Kiwi', 'Orange', 'banana', 'cherry']
['banana', 'cherry', 'Kiwi', 'Orange']
['cherry', 'Kiwi', 'Orange', 'banana']

Python - Copy Lists

Copy a List You cannot copy a list simply by typing list2 = list1, because: list2 will only be a
reference to list1, and changes made in list1 will automatically also be made in list2.

thislist = ["apple", "banana", "cherry"]


mylist = thislist.copy()
print(mylist)
# Use the list() method
thislist = ["apple", "banana", "cherry"]
mylist = list(thislist)
print(mylist)
# Use the slice Operator
thislist = ["apple", "banana", "cherry"]
mylist = thislist[:]
print(mylist)

['apple', 'banana', 'cherry']


['apple', 'banana', 'cherry']
['apple', 'banana', 'cherry']

Python - Join Lists

# Join Two Lists


list1 = ["a", "b", "c"]
list2 = [1, 2, 3]

list3 = list1 + list2


print(list3)
# method 2
list1 = ["a", "b" , "c"]
list2 = [1, 2, 3]

for x in list2:
list1.append(x)

print(list1)
# method 3
list1 = ["a", "b" , "c"]
list2 = [1, 2, 3]
list1.extend(list2)
print(list1)

['a', 'b', 'c', 1, 2, 3]


['a', 'b', 'c', 1, 2, 3]
['a', 'b', 'c', 1, 2, 3]

Python - List Methods

Python Tuples

Tuple

Tuples are used to store multiple items in a single variable.

Tuple is one of 4 built-in data types in Python used to store collections of data, the other 3 are
List, Set, and Dictionary, all with different qualities and usage.

A tuple is a collection which is ordered and unchangeable.

Tuples are written with round brackets

Tuple Items

Tuple items are ordered, unchangeable, and allow duplicate values.

Tuple items are indexed, the first item has index [0], the second item has index [1] etc.

Ordered

When we say that tuples are ordered, it means that the items have a defined order, and that
order will not change.

Unchangeable
Tuples are unchangeable, meaning that we cannot change, add or remove items after the tuple
has been created.

Allow Duplicates

Since tuples are indexed, they can have items with the same value:

# Tuple Length
thistuple = ("apple", "banana", "cherry")
print(len(thistuple))
# Create Tuple With One Item
thistuple = ("apple",)
print(type(thistuple))

#NOT a tuple
thistuple = ("apple")
print(type(thistuple))
# It is also possible to use the tuple() constructor to make a tuple.
thistuple = tuple(("apple", "banana", "cherry")) # note the double
round-brackets
print(thistuple)

3
<class 'tuple'>
<class 'str'>
('apple', 'banana', 'cherry')

Access Items same as lists

Change Tuple Values

# Convert the tuple into a list to be able to change it:

x = ("apple", "banana", "cherry")


y = list(x)
y[1] = "kiwi"
x = tuple(y)

print(x)
#any update operation can be done by converting into list and again
convert back into tuple
# The del keyword can delete the tuple completely:
thistuple = ("apple", "banana", "cherry")
del thistuple
# print(thistuple) #this will raise an error because the tuple no
longer exists

('apple', 'kiwi', 'cherry')

Python - Unpack Tuples


# Unpacking a Tuple
fruits = ("apple", "banana", "cherry")

(green, yellow, red) = fruits

print(green)
print(yellow)
print(red)
# Using Asterisk*
fruits = ("apple", "banana", "cherry", "strawberry", "raspberry")

(green, yellow, *red) = fruits

print(green)
print(yellow)
print(red)

apple
banana
cherry
apple
banana
['cherry', 'strawberry', 'raspberry']

Python Sets
Note: Sets are unordered, so you cannot be sure in which order the items will appear.

Set Items

Set items are unordered, unchangeable, and do not allow duplicate values.

Unordered

Unordered means that the items in a set do not have a defined order.

Set items can appear in a different order every time you use them, and cannot be referred to by
index or key.

Unchangeable

Set items are unchangeable, meaning that we cannot change the items after the set has been
created.

Once a set is created, you cannot change its items, but you can remove items and add new items.

Duplicates Not Allowed

Sets cannot have two items with the same value.

thisset = {"apple", "banana", "cherry"}


print(thisset)
# Note: The values True and 1 are considered the same value in sets,
and are treated as duplicates:
# Get the Length of a Set
thisset = {"apple", "banana", "cherry"}

print(len(thisset))
# It is also possible to use the set() constructor to make a set.
thisset = set(("apple", "banana", "cherry")) # note the double round-
brackets
print(thisset)

# Change Items
# Once a set is created, you cannot change its items, but you can add
new items.

{'cherry', 'banana', 'apple'}


3
{'cherry', 'banana', 'apple'}

Python - Add Set Items

thisset = {"apple", "banana", "cherry"}

thisset.add("orange")

print(thisset)
# Add Sets
# Add elements from tropical into thisset:

thisset = {"apple", "banana", "cherry"}


tropical = {"pineapple", "mango", "papaya"}

thisset.update(tropical)

print(thisset)
# Add Any Iterable
thisset = {"apple", "banana", "cherry"}
mylist = ["kiwi", "orange"]

thisset.update(mylist)

print(thisset)

{'orange', 'cherry', 'banana', 'apple'}


{'cherry', 'banana', 'papaya', 'mango', 'pineapple', 'apple'}
{'orange', 'cherry', 'kiwi', 'banana', 'apple'}

Python - Remove Set Items

To remove an item in a set, use the remove(), or the discard() method.

thisset = {"apple", "banana", "cherry"}

thisset.remove("banana")

print(thisset)
# Note: If the item to remove does not exist, remove() will raise an
error.
thisset = {"apple", "banana", "cherry"}
thisset.discard("banana")

print(thisset)
# Note: If the item to remove does not exist, discard() will NOT raise
an error.
# Remove a random item by using the pop() method:

thisset = {"apple", "banana", "cherry"}

x = thisset.pop()

print(x)

print(thisset)
# The clear() method empties the set:

thisset = {"apple", "banana", "cherry"}

thisset.clear()

print(thisset)
# The del keyword will delete the set completely:

thisset = {"apple", "banana", "cherry"}

del thisset

# print(thisset) #name 'thisset' is not defined

{'cherry', 'apple'}
{'cherry', 'apple'}
cherry
{'banana', 'apple'}
set()
Python Dictionaries
Dictionary

Dictionaries are used to store data values in key:value pairs.

A dictionary is a collection which is ordered*, changeable and do not allow duplicates.

As of Python version 3.7, dictionaries are ordered. In Python 3.6 and earlier, dictionaries are
unordered.

Dictionaries are written with curly brackets, and have keys and values:

# The dict() Constructor


thisdict = dict(name = "John", age = 36, country = "Norway")
print(thisdict)

{'name': 'John', 'age': 36, 'country': 'Norway'}

Accessing Items

# Get the value of the "model" key:

thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
x = thisdict["model"]
print(x)
# Get the value of the "model" key:

x = thisdict.get("model")
print(x)

x = thisdict.keys()
print(x)
# Get a list of the values:

x = thisdict.values()
print(x)
# Check if Key Exists
thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
if "model" in thisdict:
print("Yes, 'model' is one of the keys in the thisdict dictionary")

Mustang
Mustang
dict_keys(['brand', 'model', 'year'])
dict_values(['Ford', 'Mustang', 1964])
Yes, 'model' is one of the keys in the thisdict dictionary

Python - Change Dictionary Items

# Change the "year" to 2018:

thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
thisdict["year"] = 2018
print(thisdict)
# Update the "year" of the car by using the update() method:

thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
thisdict.update({"year": 2020})
print(thisdict)

# Adding Items
thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
thisdict["color"] = "red"
print(thisdict)
# Add a color item to the dictionary by using the update() method:

thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
thisdict.update({"color": "orange"})
print(thisdict)

{'brand': 'Ford', 'model': 'Mustang', 'year': 2018}


{'brand': 'Ford', 'model': 'Mustang', 'year': 2020}
{'brand': 'Ford', 'model': 'Mustang', 'year': 1964, 'color': 'red'}
{'brand': 'Ford', 'model': 'Mustang', 'year': 1964, 'color': 'orange'}
1. What is OOP?

Object-Oriented Programming (OOP) is a programming paradigm based on the concept of


objects, which contain data (attributes) and methods (functions).

1. Core OOP Principles

2.1 Encapsulation

Encapsulation means bundling data (attributes) and methods (functions) that operate on the
data into a single unit (class). It also allows you to restrict direct access to some attributes to
protect data.

Implementation in Python:

1.Use private variables with a double underscore __.

2.Use getter and setter methods to access or modify private variables.

class Bike:
def __init__(self, name, gear):
self.name = name
self.__gear = gear # Private attribute

def get_gear(self): # Getter


return self.__gear

def set_gear(self, gear): # Setter


self.__gear = gear

bike = Bike("Duke", 6)
print(bike.get_gear()) # Access private variable: 6
bike.set_gear(5)
print(bike.get_gear()) # Modified private variable: 5
6
5

2.2 Inheritance

Inheritance allows a class (child) to inherit attributes and methods from another class (parent),
promoting code reuse.

Types of Inheritance:

1.Single Inheritance:

class Parent:
def greet(self):
print("Hello from Parent")

class Child(Parent):
pass

child = Child()
child.greet() # Output: Hello from Parent

Hello from Parent

2.Multiple Inheritance: When a class inherits from multiple parent classes.

class Parent1:
def method(self):
print("Method from Parent1")

class Parent2:
def method(self):
print("Method from Parent2")

class Child(Parent1, Parent2):


pass

obj = Child()
obj.method() # Output: Method from Parent1 (due to Method Resolution
Order)

Method from Parent1

# 3.Multilevel inheritence
class GrandParent:
def method(self):
print("Grandparent method")

class Parent(GrandParent):
pass
class Child(Parent):
pass

obj = Child()
obj.method() # Output: Grandparent method

Grandparent method

2.3 Polymorphism

Polymorphism allows objects of different classes to be treated the same way based on shared
methods or behaviors.

Forms of Polymorphism:

1.Method Overriding (Runtime Polymorphism): A child class provides its own implementation for
a method inherited from the parent class.

class Parent:
def greet(self):
print("Hello from Parent")

class Child(Parent):
def greet(self):
print("Hello from Child")

obj = Child()
obj.greet() # Output: Hello from Child

Hello from Child

Method Overloading (Simulated in Python):

2.Python doesn't support method overloading directly, but it can be achieved with default
arguments or *args.

class Calculator:
def add(self, a, b=0):
return a + b

calc = Calculator()
print(calc.add(10)) # Output: 10
print(calc.add(10, 20)) # Output: 30

10
30

3.Operator Overloading: Using special methods to redefine operators for custom classes.
class Vector:
def __init__(self, x, y):
self.x = x
self.y = y

def __add__(self, other):


return Vector(self.x + other.x, self.y + other.y)

def __str__(self):
return f"Vector({self.x}, {self.y})"

v1 = Vector(2, 3)
v2 = Vector(1, 4)
print(v1 + v2) # Output: Vector(3, 7)

Vector(3, 7)

2.4 Abstraction

Abstraction hides implementation details and only shows essential information. It can be
achieved in Python using abstract base classes (ABC).

from abc import ABC, abstractmethod

class Shape(ABC):
@abstractmethod
def area(self):
pass

class Circle(Shape):
def __init__(self, radius):
self.radius = radius

def area(self):
return 3.14 * self.radius * self.radius

circle = Circle(5)
print(circle.area()) # Output: 78.5
class Custom:
def __init__(self, value):
self.value = value

def __str__(self):
return f"Custom({self.value})"

obj = Custom(10)
print(obj) # Output: Custom(10)

Custom(10)

class Bike:
def __init__(self, name="Default", gear=1):
self.name = name
self.gear = gear

@classmethod
def electric_bike(cls):
return cls("Electric Bike", 0)

bike1 = Bike()
bike2 = Bike.electric_bike()

print(bike1.name, bike1.gear) # Output: Default 1


print(bike2.name, bike2.gear) # Output: Electric Bike 0

Default 1
Electric Bike 0

class Example:
counter = 0
@classmethod
def increment_counter(cls):
cls.counter += 1
return cls.counter

# Access through the class


print(Example.increment_counter()) # Output: 1
print(Example.increment_counter()) # Output: 2

# Access through an instance


instance = Example()
print(instance.increment_counter()) # Output: 3

class Person:
def __init__(self, name, age):
self.name = name
self.age = age

@classmethod
def from_string(cls, data_string):
name, age = data_string.split(',')
return cls(name, int(age))

# Create an instance using the class method


person = Person.from_string("John,30")
print(person.name) # Output: John
print(person.age) # Output: 30

1
2
3
John
30
class Example:
def __init__(self):
self.public = "Public"
self._protected = "Protected"
self.__private = "Private"

obj = Example()
print(obj.public) # Output: Public
print(obj._protected) # Output: Protected
# print(obj.__private) # Error

Public
Protected

# 4. Real-Life Example of OOP


class Account:
def __init__(self, owner, balance=0):
self.owner = owner
self.__balance = balance

def deposit(self, amount):


self.__balance += amount
print(f"{amount} deposited. New balance is {self.__balance}.")

def withdraw(self, amount):


if amount > self.__balance:
print("Insufficient funds!")
else:
self.__balance -= amount
print(f"{amount} withdrawn. New balance is
{self.__balance}.")
def get_balance(self):
return self.__balance

# Usage
acc = Account("Ranjith", 1000)
acc.deposit(500) # Output: 500 deposited. New balance is 1500.
acc.withdraw(2000) # Output: Insufficient funds!
print(acc.get_balance()) # Output: 1500

500 deposited. New balance is 1500.


Insufficient funds!
1500

Python Functions

A function is a block of code which only runs when it is called.

You can pass data, known as parameters, into a function.

A function can return data as a result.

Creating a Function

In Python a function is defined using the def keyword:

def my_function():#defining the function


print("Hello from a function")

my_function() #calling the function

Arguments

Information can be passed into functions as arguments.


Arguments are specified after the function name, inside the parentheses. You can add as many
arguments as you want, just separate them with a comma.

The following example has a function with one argument (fname). When the function is called,
we pass along a first name, which is used inside the function to print the full name:

def my_function(fname):
print(fname + " Refsnes")

my_function("Emil")
my_function("Tobias")
my_function("Linus")

Emil Refsnes
Tobias Refsnes
Linus Refsnes

Parameters or Arguments?

The terms parameter and argument can be used for the same thing: information that are passed
into a function.

From a function's perspective:

A parameter is the variable listed inside the parentheses in the function definition.

An argument is the value that is sent to the function when it is called.

Number of Arguments

By default, a function must be called with the correct number of arguments. Meaning that if your
function expects 2 arguments, you have to call the function with 2 arguments, not more, and not
less.

# This function expects 2 arguments, and gets 2 arguments:

def my_function(fname, lname):


print(fname + " " + lname)

my_function("Emil", "Refsnes")
# If you try to call the function with 1 or 3 arguments, you will get
an error:

Arbitrary Arguments, *args

If you do not know how many arguments that will be passed into your function, add a * before
the parameter name in the function definition.

This way the function will receive a tuple of arguments, and can access the items accordingly:

# If the number of arguments is unknown, add a * before the parameter


name:
def my_function(*kids):
print("The youngest child is " + kids[0])

my_function("Emil","Tobias", "Linus")

The youngest child is Emil

Keyword Arguments

You can also send arguments with the key = value syntax.

This way the order of the arguments does not matter

def my_function(child3, child2, child1):


print("The youngest child is " + child3)

my_function(child1 = "Emil", child3 = "Linus", child2 = "Tobias")

The youngest child is Linus

Arbitrary Keyword Arguments, **kwargs

If you do not know how many keyword arguments that will be passed into your function, add
two asterisk: ** before the parameter name in the function definition.

This way the function will receive a dictionary of arguments, and can access the items
accordingly:

def my_function(**kid):
print("His last name is " + kid["lname"])

my_function(fname = "Tobias", lname = "Refsnes")

His last name is Refsnes

Position-Only Parameters (/)

Position-only parameters can only be provided by their position in the argument list, not by their
name. To specify that parameters are position-only, a / is used in the function definition.

def func(a, b, /, c):


print(a, b, c)

func(1,2,3)
func(1,2,c=3)
# In this example:

# a and b are position-only parameters.


# c can be passed either by position or as a keyword.
def greet(first_name, /, last_name):
print(f"Hello, {first_name} {last_name}!")

# Valid calls:
greet("John", "Doe") # Output: Hello, John Doe!

# Invalid call:
# greet(first_name="John", last_name="Doe") # Raises TypeError

1 2 3
1 2 3
Hello, John Doe!

def func(*, a, b):


print(a, b)

# In this example:
# Both a and b are keyword-only parameters.

def greet(*, first_name, last_name):


print(f"Hello, {first_name} {last_name}!")

# Valid call:
greet(first_name="John", last_name="Doe") # Output: Hello, John Doe!

# Invalid call:
# greet("John", "Doe") # Raises TypeError

Hello, John Doe!


def func(a, b, /, c, *, d, e):
print(a, b, c, d, e)

def config(x, /, y, *, z):


print(f"x={x}, y={y}, z={z}")

# Valid calls:
config(1, 2, z=3) # Output: x=1, y=2, z=3

# Invalid calls:
# config(x=1, y=2, z=3) # Raises TypeError
# config(1, 2, 3) # Raises TypeError

x=1, y=2, z=3


def tri_recursion(k):
if(k > 0):
result = k + tri_recursion(k - 1)
print(result)
else:
result = 0
return result

print("Recursion Example Results:")


tri_recursion(6)

Recursion Example Results:


1
3
6
10
15
21

21

ERROR: pip's dependency resolver does not currently take into account
all the packages that are installed. This behaviour is the source of
the following dependency conflicts.
streamlit 1.32.0 requires packaging<24,>=16.8, but you have packaging
24.1 which is incompatible.

Collecting notebook-as-pdf
Using cached notebook_as_pdf-0.5.0-py3-none-any.whl.metadata (2.4
kB)
Requirement already satisfied: nbconvert in c:\users\ranjith\
anaconda3\lib\site-packages (from notebook-as-pdf) (7.10.0)
Collecting pyppeteer (from notebook-as-pdf)
Using cached pyppeteer-2.0.0-py3-none-any.whl.metadata (7.1 kB)
Collecting PyPDF2 (from notebook-as-pdf)
Using cached pypdf2-3.0.1-py3-none-any.whl.metadata (6.8 kB)
Requirement already satisfied: beautifulsoup4 in c:\users\ranjith\
anaconda3\lib\site-packages (from nbconvert->notebook-as-pdf) (4.12.3)
Requirement already satisfied: bleach!=5.0.0 in c:\users\ranjith\
anaconda3\lib\site-packages (from nbconvert->notebook-as-pdf) (4.1.0)
Requirement already satisfied: defusedxml in c:\users\ranjith\
anaconda3\lib\site-packages (from nbconvert->notebook-as-pdf) (0.7.1)
Requirement already satisfied: jinja2>=3.0 in c:\users\ranjith\
anaconda3\lib\site-packages (from nbconvert->notebook-as-pdf) (3.1.4)
Requirement already satisfied: jupyter-core>=4.7 in c:\users\ranjith\
appdata\roaming\python\python312\site-packages (from nbconvert-
>notebook-as-pdf) (5.7.2)
Requirement already satisfied: jupyterlab-pygments in c:\users\
ranjith\anaconda3\lib\site-packages (from nbconvert->notebook-as-pdf)
(0.1.2)
Requirement already satisfied: markupsafe>=2.0 in c:\users\ranjith\
anaconda3\lib\site-packages (from nbconvert->notebook-as-pdf) (2.1.3)
Requirement already satisfied: mistune<4,>=2.0.3 in c:\users\ranjith\
anaconda3\lib\site-packages (from nbconvert->notebook-as-pdf) (2.0.4)
Requirement already satisfied: nbclient>=0.5.0 in c:\users\ranjith\
anaconda3\lib\site-packages (from nbconvert->notebook-as-pdf) (0.8.0)
Requirement already satisfied: nbformat>=5.7 in c:\users\ranjith\
anaconda3\lib\site-packages (from nbconvert->notebook-as-pdf) (5.9.2)
Requirement already satisfied: packaging in c:\users\ranjith\appdata\
roaming\python\python312\site-packages (from nbconvert->notebook-as-
pdf) (24.1)
Requirement already satisfied: pandocfilters>=1.4.1 in c:\users\
ranjith\anaconda3\lib\site-packages (from nbconvert->notebook-as-pdf)
(1.5.0)
Requirement already satisfied: pygments>=2.4.1 in c:\users\ranjith\
appdata\roaming\python\python312\site-packages (from nbconvert-
>notebook-as-pdf) (2.18.0)
Requirement already satisfied: tinycss2 in c:\users\ranjith\anaconda3\
lib\site-packages (from nbconvert->notebook-as-pdf) (1.2.1)
Requirement already satisfied: traitlets>=5.1 in c:\users\ranjith\
appdata\roaming\python\python312\site-packages (from nbconvert-
>notebook-as-pdf) (5.14.3)
Requirement already satisfied: appdirs<2.0.0,>=1.4.3 in c:\users\
ranjith\anaconda3\lib\site-packages (from pyppeteer->notebook-as-pdf)
(1.4.4)
Requirement already satisfied: certifi>=2023 in c:\users\ranjith\
anaconda3\lib\site-packages (from pyppeteer->notebook-as-pdf)
(2024.6.2)
Requirement already satisfied: importlib-metadata>=1.4 in c:\users\
ranjith\anaconda3\lib\site-packages (from pyppeteer->notebook-as-pdf)
(7.0.1)
Collecting pyee<12.0.0,>=11.0.0 (from pyppeteer->notebook-as-pdf)
Using cached pyee-11.1.1-py3-none-any.whl.metadata (2.8 kB)
Requirement already satisfied: tqdm<5.0.0,>=4.42.1 in c:\users\
ranjith\anaconda3\lib\site-packages (from pyppeteer->notebook-as-pdf)
(4.66.4)
Collecting urllib3<2.0.0,>=1.25.8 (from pyppeteer->notebook-as-pdf)
Using cached urllib3-1.26.20-py2.py3-none-any.whl.metadata (50 kB)
Collecting websockets<11.0,>=10.0 (from pyppeteer->notebook-as-pdf)
Using cached websockets-10.4.tar.gz (84 kB)
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'done'
Requirement already satisfied: six>=1.9.0 in c:\users\ranjith\
anaconda3\lib\site-packages (from bleach!=5.0.0->nbconvert->notebook-
as-pdf) (1.16.0)
Requirement already satisfied: webencodings in c:\users\ranjith\
anaconda3\lib\site-packages (from bleach!=5.0.0->nbconvert->notebook-
as-pdf) (0.5.1)
Requirement already satisfied: zipp>=0.5 in c:\users\ranjith\
anaconda3\lib\site-packages (from importlib-metadata>=1.4->pyppeteer-
>notebook-as-pdf) (3.17.0)
Requirement already satisfied: platformdirs>=2.5 in c:\users\ranjith\
appdata\roaming\python\python312\site-packages (from jupyter-
core>=4.7->nbconvert->notebook-as-pdf) (4.2.2)
Requirement already satisfied: pywin32>=300 in c:\users\ranjith\
anaconda3\lib\site-packages (from jupyter-core>=4.7->nbconvert-
>notebook-as-pdf) (305.1)
Requirement already satisfied: jupyter-client>=6.1.12 in c:\users\
ranjith\appdata\roaming\python\python312\site-packages (from
nbclient>=0.5.0->nbconvert->notebook-as-pdf) (8.6.2)
Requirement already satisfied: fastjsonschema in c:\users\ranjith\
anaconda3\lib\site-packages (from nbformat>=5.7->nbconvert->notebook-
as-pdf) (2.16.2)
Requirement already satisfied: jsonschema>=2.6 in c:\users\ranjith\
anaconda3\lib\site-packages (from nbformat>=5.7->nbconvert->notebook-
as-pdf) (4.19.2)
Requirement already satisfied: typing-extensions in c:\users\ranjith\
anaconda3\lib\site-packages (from pyee<12.0.0,>=11.0.0->pyppeteer-
>notebook-as-pdf) (4.11.0)
Requirement already satisfied: colorama in c:\users\ranjith\anaconda3\
lib\site-packages (from tqdm<5.0.0,>=4.42.1->pyppeteer->notebook-as-
pdf) (0.4.6)
Requirement already satisfied: soupsieve>1.2 in c:\users\ranjith\
anaconda3\lib\site-packages (from beautifulsoup4->nbconvert->notebook-
as-pdf) (2.5)
Requirement already satisfied: attrs>=22.2.0 in c:\users\ranjith\
anaconda3\lib\site-packages (from jsonschema>=2.6->nbformat>=5.7-
>nbconvert->notebook-as-pdf) (23.1.0)
Requirement already satisfied: jsonschema-specifications>=2023.03.6 in
c:\users\ranjith\anaconda3\lib\site-packages (from jsonschema>=2.6-
>nbformat>=5.7->nbconvert->notebook-as-pdf) (2023.7.1)
Requirement already satisfied: referencing>=0.28.4 in c:\users\
ranjith\anaconda3\lib\site-packages (from jsonschema>=2.6-
>nbformat>=5.7->nbconvert->notebook-as-pdf) (0.30.2)
Requirement already satisfied: rpds-py>=0.7.1 in c:\users\ranjith\
anaconda3\lib\site-packages (from jsonschema>=2.6->nbformat>=5.7-
>nbconvert->notebook-as-pdf) (0.10.6)
Requirement already satisfied: python-dateutil>=2.8.2 in c:\users\
ranjith\anaconda3\lib\site-packages (from jupyter-client>=6.1.12-
>nbclient>=0.5.0->nbconvert->notebook-as-pdf) (2.9.0.post0)
Requirement already satisfied: pyzmq>=23.0 in c:\users\ranjith\
appdata\roaming\python\python312\site-packages (from jupyter-
client>=6.1.12->nbclient>=0.5.0->nbconvert->notebook-as-pdf) (26.2.0)
Requirement already satisfied: tornado>=6.2 in c:\users\ranjith\
appdata\roaming\python\python312\site-packages (from jupyter-
client>=6.1.12->nbclient>=0.5.0->nbconvert->notebook-as-pdf) (6.4.1)
Using cached notebook_as_pdf-0.5.0-py3-none-any.whl (6.5 kB)
Downloading pypdf2-3.0.1-py3-none-any.whl (232 kB)
---------------------------------------- 0.0/232.6 kB ? eta -:--:--
- -------------------------------------- 10.2/232.6 kB ? eta
-:--:--
----- --------------------------------- 30.7/232.6 kB 262.6 kB/s
eta 0:00:01
------ -------------------------------- 41.0/232.6 kB 281.8 kB/s
eta 0:00:01
---------- ---------------------------- 61.4/232.6 kB 297.7 kB/s
eta 0:00:01
------------ -------------------------- 71.7/232.6 kB 280.5 kB/s
eta 0:00:01
------------ -------------------------- 71.7/232.6 kB 280.5 kB/s
eta 0:00:01
------------ -------------------------- 71.7/232.6 kB 280.5 kB/s
eta 0:00:01
------------ -------------------------- 71.7/232.6 kB 280.5 kB/s
eta 0:00:01
------------ -------------------------- 71.7/232.6 kB 280.5 kB/s
eta 0:00:01
------------ -------------------------- 71.7/232.6 kB 280.5 kB/s
eta 0:00:01
------------ -------------------------- 71.7/232.6 kB 280.5 kB/s
eta 0:00:01
------------ -------------------------- 71.7/232.6 kB 280.5 kB/s
eta 0:00:01
------------ -------------------------- 71.7/232.6 kB 280.5 kB/s
eta 0:00:01
------------ -------------------------- 71.7/232.6 kB 280.5 kB/s
eta 0:00:01
------------ -------------------------- 71.7/232.6 kB 280.5 kB/s
eta 0:00:01
------------ -------------------------- 71.7/232.6 kB 280.5 kB/s
eta 0:00:01
------------ -------------------------- 71.7/232.6 kB 280.5 kB/s
eta 0:00:01
------------ -------------------------- 71.7/232.6 kB 280.5 kB/s
eta 0:00:01
------------ -------------------------- 71.7/232.6 kB 280.5 kB/s
eta 0:00:01
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
--------------- ------------------------ 92.2/232.6 kB 83.3 kB/s
eta 0:00:02
------------------ -------------------- 112.6/232.6 kB 37.2 kB/s
eta 0:00:04
------------------ -------------------- 112.6/232.6 kB 37.2 kB/s
eta 0:00:04
-------------------- ------------------ 122.9/232.6 kB 39.8 kB/s
eta 0:00:03
-------------------- ------------------ 122.9/232.6 kB 39.8 kB/s
eta 0:00:03
-------------------- ------------------ 122.9/232.6 kB 39.8 kB/s
eta 0:00:03
-------------------- ------------------ 122.9/232.6 kB 39.8 kB/s
eta 0:00:03
------------------------ -------------- 143.4/232.6 kB 43.9 kB/s
eta 0:00:03
------------------------- ------------- 153.6/232.6 kB 46.8 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
----------------------------- --------- 174.1/232.6 kB 52.7 kB/s
eta 0:00:02
------------------------------------- - 225.3/232.6 kB 46.0 kB/s
eta 0:00:01
--------------------------------------- 232.6/232.6 kB 47.4 kB/s
eta 0:00:00
Downloading pyppeteer-2.0.0-py3-none-any.whl (82 kB)
---------------------------------------- 0.0/82.9 kB ? eta -:--:--
---------------------------------------- 0.0/82.9 kB ? eta -:--:--
---------------------------------------- 0.0/82.9 kB ? eta -:--:--
---------------------------------------- 0.0/82.9 kB ? eta -:--:--
---------------------------------------- 0.0/82.9 kB ? eta -:--:--
---------------------------------------- 0.0/82.9 kB ? eta -:--:--
---- ----------------------------------- 10.2/82.9 kB ? eta -:--:--
---- ----------------------------------- 10.2/82.9 kB ? eta -:--:--
---- ----------------------------------- 10.2/82.9 kB ? eta -:--:--
-------------- ------------------------- 30.7/82.9 kB 131.3 kB/s
eta 0:00:01
-------------- ------------------------- 30.7/82.9 kB 131.3 kB/s
eta 0:00:01
-------------- ------------------------- 30.7/82.9 kB 131.3 kB/s
eta 0:00:01
------------------- -------------------- 41.0/82.9 kB 122.9 kB/s
eta 0:00:01
------------------- -------------------- 41.0/82.9 kB 122.9 kB/s
eta 0:00:01
----------------------------- ---------- 61.4/82.9 kB 136.5 kB/s
eta 0:00:01
----------------------------- ---------- 61.4/82.9 kB 136.5 kB/s
eta 0:00:01
---------------------------------------- 82.9/82.9 kB 160.4 kB/s
eta 0:00:00
Downloading pyee-11.1.1-py3-none-any.whl (15 kB)
Downloading urllib3-1.26.20-py2.py3-none-any.whl (144 kB)
---------------------------------------- 0.0/144.2 kB ? eta -:--:--
---------------------------------------- 0.0/144.2 kB ? eta -:--:--
-- ------------------------------------- 10.2/144.2 kB ? eta
-:--:--
-- ------------------------------------- 10.2/144.2 kB ? eta
-:--:--
-- ------------------------------------- 10.2/144.2 kB ? eta
-:--:--
-- ------------------------------------- 10.2/144.2 kB ? eta
-:--:--
-- ------------------------------------- 10.2/144.2 kB ? eta
-:--:--
-------- ------------------------------- 30.7/144.2 kB 93.5 kB/s
eta 0:00:02
-------- ------------------------------- 30.7/144.2 kB 93.5 kB/s
eta 0:00:02
-------- ------------------------------- 30.7/144.2 kB 93.5 kB/s
eta 0:00:02
---------------- ---------------------- 61.4/144.2 kB 136.5 kB/s
eta 0:00:01
---------------- ---------------------- 61.4/144.2 kB 136.5 kB/s
eta 0:00:01
---------------- ---------------------- 61.4/144.2 kB 136.5 kB/s
eta 0:00:01
------------------- ------------------- 71.7/144.2 kB 115.7 kB/s
eta 0:00:01
-------------------------- ----------- 102.4/144.2 kB 159.4 kB/s
eta 0:00:01
-------------------------- ----------- 102.4/144.2 kB 159.4 kB/s
eta 0:00:01
-------------------------- ----------- 102.4/144.2 kB 159.4 kB/s
eta 0:00:01
-------------------------- ----------- 102.4/144.2 kB 159.4 kB/s
eta 0:00:01
-------------------------- ----------- 102.4/144.2 kB 159.4 kB/s
eta 0:00:01
-------------------------- ----------- 102.4/144.2 kB 159.4 kB/s
eta 0:00:01
-------------------------- ----------- 102.4/144.2 kB 159.4 kB/s
eta 0:00:01
-------------------------- ----------- 102.4/144.2 kB 159.4 kB/s
eta 0:00:01
-------------------------- ----------- 102.4/144.2 kB 159.4 kB/s
eta 0:00:01
-------------------------- ----------- 102.4/144.2 kB 159.4 kB/s
eta 0:00:01
--------------------------------- ----- 122.9/144.2 kB 91.3 kB/s
eta 0:00:01
--------------------------------- ----- 122.9/144.2 kB 91.3 kB/s
eta 0:00:01
--------------------------------- ----- 122.9/144.2 kB 91.3 kB/s
eta 0:00:01
--------------------------------- ----- 122.9/144.2 kB 91.3 kB/s
eta 0:00:01
--------------------------------- ----- 122.9/144.2 kB 91.3 kB/s
eta 0:00:01
--------------------------------- ----- 122.9/144.2 kB 91.3 kB/s
eta 0:00:01
--------------------------------- ----- 122.9/144.2 kB 91.3 kB/s
eta 0:00:01
--------------------------------- ----- 122.9/144.2 kB 91.3 kB/s
eta 0:00:01
--------------------------------- ----- 122.9/144.2 kB 91.3 kB/s
eta 0:00:01
--------------------------------- ----- 122.9/144.2 kB 91.3 kB/s
eta 0:00:01
--------------------------------- ----- 122.9/144.2 kB 91.3 kB/s
eta 0:00:01
--------------------------------- ----- 122.9/144.2 kB 91.3 kB/s
eta 0:00:01
--------------------------------------- 144.2/144.2 kB 73.3 kB/s
eta 0:00:00
Building wheels for collected packages: websockets
Building wheel for websockets (setup.py): started
Building wheel for websockets (setup.py): finished with status
'done'
Created wheel for websockets: filename=websockets-10.4-cp312-cp312-
win_amd64.whl size=95035
sha256=3c96bd8c4575fb693c3ce5195c3bc1d0a909db0e19db1dc8a9ac7bae4e5996d
d
Stored in directory: c:\users\ranjith\appdata\local\pip\cache\
wheels\80\cf\6d\5d7e4c920cb41925a178b2d2621889c520d648bab487b1d7fd
Successfully built websockets
Installing collected packages: websockets, urllib3, PyPDF2, pyee,
pyppeteer, notebook-as-pdf
Attempting uninstall: urllib3
Found existing installation: urllib3 2.2.2
Uninstalling urllib3-2.2.2:
Successfully uninstalled urllib3-2.2.2
Successfully installed PyPDF2-3.0.1 notebook-as-pdf-0.5.0 pyee-11.1.1
pyppeteer-2.0.0 urllib3-1.26.20 websockets-10.4

You might also like