0% found this document useful (0 votes)
4 views3 pages

Group A Assign 4 String

The document outlines an assignment for a Data Structure Laboratory course focused on string operations in Python. It includes objectives, a problem statement requiring the implementation of various string functions, and theoretical explanations of strings and related concepts. Additionally, it provides FAQs related to string handling in Python.

Uploaded by

cgraphics53
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)
4 views3 pages

Group A Assign 4 String

The document outlines an assignment for a Data Structure Laboratory course focused on string operations in Python. It includes objectives, a problem statement requiring the implementation of various string functions, and theoretical explanations of strings and related concepts. Additionally, it provides FAQs related to string handling in Python.

Uploaded by

cgraphics53
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/ 3

Data Structure Laboratory SE- Comp 2022-23

Group: A Roll No:

Assignment No: 2 Date:

Title:

Write a python program to compute following operations on String:


a) To display word with the longest length
b) To determines the frequency of occurrence of particular character in the string
c) To check whether given string is palindrome or not
d) To display index of first appearance of the substring
e) To count the occurrences of each word in a given string

Marks: Sign:

Department of Computer Engineering Sinhgad Institute of Technology, Lonavala


Data Structure Laboratory SE- Comp 2022-23

Group A

Assignment No. A2

Title: String Operations

Objectives:

To implement different operations on strings like Creating, copying, modifying,


concatenating, reversing , Finding substrings, etc.

To simulate the inbuilt string operations function.

Problem Statement:

Write a python program to compute following operations on String:


a) To display word with the longest length
b) To determines the frequency of occurrence of particular character in the string
c) To check whether given string is palindrome or not
d) To display index of first appearance of the substring
e) To count the occurrences of each word in a given string

Input:

Input a string. Ex. string1=’ ‘

Output:

1. To display word with the longest length


2. Frequency of occurrence of particular character in the string
3. String is palindrome or not
4. Index of first appearance of the substring
5. Occurrences of each word in a given string

Theory

Explain string with example.

Algorithm/ Pseudo code for following:

1. Display word with the longest length


2. Determines the frequency of occurrence of particular character in the string
3. Check whether given string is palindrome or not
4. Display index of first appearance of the substring

Department of Computer Engineering Sinhgad Institute of Technology, Lonavala


Data Structure Laboratory SE- Comp 2022-23

5. Count the occurrences of each word in a given string

STRINGS

A string is an array of characters ended with NULL character (‘\0’). This null character
indicates the end of the string. Strings are always enclosed by double quotes; whereas,
character is enclosed by single quotes in C. Each character is stored in 1 byte as its ASCII
code.

Substring : A string is a substring of a main string if it is a part of the main string.


Palindrome : A string is a palindrome if reverse of the string is equal to the original string.
e.g : nitin

Different string operations are as follows :


1. int strlen( const char *str) -- Calculates string length excluding last null character.
2. char * strcpy( char *dest, const char * src) – Copies string from source to destination
3. char *strcat(char *dest, const char * src ) – Appends source string at the end of
destination and returns pointer to destination
4. int strcmp(const char *str1, const char * str2) – Does unsigned comparison of two strings
character by character and returns difference as integer.
5. String palindrome – Checking if reversed string is same as original string.

Conclusion:

Thus the string have been implemented (without using standard library routines).

FAQs:-

1) What is a string in Python with example?


2) How strings are stored in Python?
3) Is there any difference between 1 and ‘1’? Explain.
4) Write a python program where first and last character of the string have been
exchanged.
5) What do you mean by string slicing?
6) Explain any 5 build-in methods for string with example in python.
7) What is difference between find() and index() function for string in python

Department of Computer Engineering Sinhgad Institute of Technology, Lonavala

You might also like