Data Analysis using Python Lab
Ex : No.1
Python Data Structures: Develop an application
that uses different python data structures
Dictionaries
Lists
Tuples
Sets
Different Users of Inbuilt Data Structure:
Tuples:
a)To provide easy access to a dataSet and easy manipulation
of a data set.
b)Through a single Parameter passing multiple values.
Dictionary:
a)Used to store unordered key-value pairs.
b)Anything can be used to store the data and to access them
basically.
List:
a)Multiple data types are stored and multiple actions can be
performed too.
b)Easy access and manipulation of data sets.
Set:
a)To store unique data basically.
Create a Dictionary,Add Elements in it,Display it,Access Keys and
Values,Display the Key and Value Pairs.
Create a List,Add Elements in it by append(),extend(),insert() and
display the result,Delete elements from the list,Display the
Result
Create a Tuple,Append Elements in Tuple,Display the Results
Create Sets,Add Elements in it,perform operations
(union,intersection,difference and symmetric
difference),Display the Results
Python String Functions
The Python String Functions which we are going to discuss in this
article are as follows:
• capitalize( ) function
• lower( ) function
• title( ) function
• casefold( ) function
• upper( ) function
• count( ) function
• find( ) function
• replace( ) function
• swapcase( ) function
• join( ) function
Python String Functions
capitalize( ) function
• The capitalize() function returns a string where the first
character is the upper case.
Syntax: string.capitalize()
Example 1: Make the first letter upper case in the given
sentence
string = “cmr university soet“
print(string.capitalize())
• Output:
Cmr university soet
Python String Functions
lower( ) function
• The lower() function returns a string where all the
characters in a given string are lower case. This
function doesn’t do anything with Symbols and
Numbers i.e, simply ignored these things.
Syntax: string.lower() Example 1: Lower case the given
string
• string = "Cmr University Soet“
• print(string.lower())
• Output:
cmr university soet
Python String Functions
upper( ) function
• The upper() function returns a string where all the characters
in a given string are in the upper case. This function doesn’t
do anything with Symbols and Numbers i.e, simply ignored
these things.
Syntax: string.upper()
Example 1: Upper case the given string
• string = “cmr university is one of the top university in
karnataka“
• print(string.upper())
Output
CMR UNIVERSITY IS ONE OF THE TOP UNIVERSITY IN KARNATAKA
Python String Functions
title( ) function
• The title() function returns a string where the first character in
every word of the string is an upper case. It is just like a
header, or a title.
• If in a string any of the words contain either a number or a
symbol, then this function converts the first letter after that to
upper case.
Syntax: string.title()
Example 1: Make the first letter in each word upper case
string = " cmr university soet “
print(string.title())
• Output:
Cmr University Soet
Ex.no: 2
Execute the following Python String Functions and print the
output
• capitalize( ) function
• lower( ) function
• title( ) function
• casefold( ) function
• upper( ) function
• count( ) function
• find( ) function
• replace( ) function
• swapcase( ) function
• join( ) function