100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Class notes

Python Language Programming Lab

Rating
-
Sold
-
Pages
4
Uploaded on
03-03-2023
Written in
2022/2023

Python Language Programming Lab

Institution
Course








Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Course

Document information

Uploaded on
March 3, 2023
Number of pages
4
Written in
2022/2023
Type
Class notes
Professor(s)
Rahul kumar
Contains
All classes

Subjects

Content preview

Python Language Programming Lab
Laboratory Notes (3)

Topic:
1. Write programs to demonstrate use of strings and its functions


Objective:
Write programs to demonstrate use of strings and its functions
Description:
A string is a sequence of characters. You can access the characters one at a time with
the bracket operator:
fruit = 'banana'
letter = fruit[1]
The second statement extracts the character at index position 1 from the fruit variable and
assigns it to the letter variable. The expression in brackets is called an index.


String functions:
len is a built-in function that returns the number of characters in a string:
>>> fruit = 'banana'
>>> len(fruit)
Output: 6


String Slicing:
A segment of a string is called a slice. Selecting a slice is similar to selecting a
character:
>>> s = 'Monty Python'
>>> print s[6:12]
Output: Python
The operator [n: m] returns the part of the string from the “n-th” character to the “m-th”
character, including the first but excluding the last. Strings are immutable, which means
$7.99
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
devidkumar

Get to know the seller

Seller avatar
devidkumar delhi technical university
Follow You need to be logged in order to follow users or courses
Sold
0
Member since
2 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

Frequently asked questions