Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

handwritten notes pps

Rating
-
Sold
-
Pages
10
Uploaded on
20-06-2024
Written in
2023/2024

PPS handwritten notes are additional remarks made after the main text, often written by hand to provide extra details, explanations, or updates. They serve to enrich the content by addressing related points or emphasizing key information that may not have been fully covered in the original document. These notes can clarify complex concepts, offer new insights, or respond to questions raised during the discussion. PPS notes are valuable for ensuring comprehensive understanding and are commonly used in academic papers, business communications, and personal correspondence to supplement and enhance the main message.

Show more Read less
Institution
Course

Content preview

PPS UNIT -04 STRINGS
Q.1 what is string. How we concatenate two strings.
1. Python string data type is a sequence of characters.
2. Characters could be a letter, digit, whitespace or any other symbol.
3. Python treats strings as contiguous series of characters delimited/enclosed by single, double or triple quotes.
4. Python has built in string class str
5. We can declare and define a string by creating a variable of string type.
6. str() is used to convert values of any other type into string type.
7. Example-
name=“India”
country=name
division=str(“FE-G”)

Q.2 Explain String indexing and string Traversing with Give Example.
String Indexing and String Traversing-
String Indexing-
1. Individual characters in a string are accessed using the subscript ([]) operator.
2. The expression in bracket called index
3. Index specifies the character we want to access from given set of characters in a string.
4. Index of first character is 0 and index of last character is n-1. nis number of character in string.
5. Every symbol in string having its own index.




String Traversing-
A string can be traversed by accessing characters from one index to another.




Q.3 write a note on string format operator.
String Format Operator %
1. The format operator, % allows users to construct strings, replacing parts of the strings with data stored in variables.
2. The % operator takes a format string on left (%d, %s) and the corresponding values in tuple on the right.
3. Multiple values added in parenthesis and separated by comma.

, Following are the format sequence-
i. %s - String (or any object with a string representation, like numbers)
ii. %c- single character
iii. %d or %i – Integers
iv. %u- unsigned decimal integer
v. %f - Floating point numbers
vi. %.<number of digits>f - Floating point numbers with a fixed amount of digits to the right of the dot.
vii. %o- Octal integer
viii. %x - Integers in hex representation
Syntax and Example of String Formating operator %
“<format>” %(<values>)
Format consist of sequence of character and conversion specification.
Conversion specification start with a % operator and can appear anywhere within a string.
Example- Program to use format sequence while printing a string
name=“abcd”
rollno=35
print(“name is %s and rollno is %d” %( name, rollno))
output- name is abcd and rollno is 35

Q.4 Explain use of format() method with help of example.
Format() method and { } placeholder
1. The format function used with strings is very powerful function used for formatting string.
2. Format string have curly braces { } as placeholder which get replaced.
3. We can use positional argument or keyword arguments to specify the order of fields which have to be replace.
4. Example-
a="welcome“
b="python“
print("{ } to learning { }".format( a, b))
print("{b} for learning {a}".format(b = "easy", a = "language“ ))
OUTPUT-
welcome to learning python
easy for learning language
Q.5 What is slice operation? Explain with example.

Written for

Institution
Course

Document information

Uploaded on
June 20, 2024
Number of pages
10
Written in
2023/2024
Type
Class notes
Professor(s)
Sid gunja;
Contains
All classes

Subjects

$4.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
sidgunjal

Get to know the seller

Seller avatar
sidgunjal avcoe
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
1 year
Number of followers
0
Documents
5
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions