0% found this document useful (0 votes)
7 views2 pages

3.python Datatypes

The document provides an overview of Python's dynamic typing and various data types including string, integer, float, and boolean. It explains string manipulation techniques such as indexing, slicing, and using supportive functions like upper(), lower(), and isalpha(). Additionally, it demonstrates how to extract specific characters or substrings from strings using different methods.

Uploaded by

prpt2608
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)
7 views2 pages

3.python Datatypes

The document provides an overview of Python's dynamic typing and various data types including string, integer, float, and boolean. It explains string manipulation techniques such as indexing, slicing, and using supportive functions like upper(), lower(), and isalpha(). Additionally, it demonstrates how to extract specific characters or substrings from strings using different methods.

Uploaded by

prpt2608
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/ 2

In [ ]: #Python is a dynamically typed programming language coz no need to specify datatype every time we assign a value to a variable

In [2]: a= "sunil"
type(a)

Out[2]: str

In [3]: b= 13
type(b)

Out[3]: int

In [4]: c= 3.17
type(c)

Out[4]: float

In [6]: d = True
type(d)

Out[6]: bool

In [ ]: # Datatypes

1. str
2. int
3. float
4. bool

In [ ]: #### 1. Str Datatype

#1.any character of str datatype can be accessed by []

In [9]: a="sunil"
print(a)
type(a)

sunil
Out[9]: str

In [16]: b="sunil_lambe"
b[0]
b[5]
b[9]

Out[16]: 'b'

In [19]: a="datavizon" # Extract data


a[0:4] #start:end, end will be excludedd, Always end with end+1

Out[19]: 'data'

In [20]: a="Engineering" # Extract engineering


a[0:8]

Out[20]: 'Engineer'

In [22]: a="KSR Datavizon" # Extract data


a[4:8]

Out[22]: 'Data'

In [23]: a="KSR is the best Institute" # Extract The best


a[7:15]

Out[23]: 'the best'

In [24]: a="Python is my fav language" # Extract my fav


a[10:16]

Out[24]: 'my fav'

In [27]: a="datavizon" # extract dtvzn using step i.e (start:end:step)


a[0:9:1] # datavizon
a[0:9:2] #dtvzn

Out[27]: 'dtvzn'

In [28]: a="santhosh" #extract snhs


a[0:7:2]

Out[28]: 'snhs'

In [29]: a="dataengineering" #extract dag


a[0:7:3]

Out[29]: 'dag'

In [2]: a= "python" # Extract po


a[0:5:4]

Out[2]: 'po'

In [13]: #### Supportive function for string datatype

a ="Sunil"

In [2]: a.upper() #### convert the string into uppercase

Out[2]: 'SUNIL'

In [3]: a.lower() #### convert string into lowercase

Out[3]: 'sunil'

In [4]: a.capitalize() ### Convert first letter into uppercase

Out[4]: 'Sunil'

In [5]: a.casefold() ####used to normalize a string to a case-insensitive form. It is similar to the lower() method
####but is more aggressive in handling different Unicode characters

Out[5]: 'sunil'

In [8]: a.isnumeric() ####Check if it is a numeric value

Out[8]: False

In [9]: a.isalpha() #### check if it is an alphabet

Out[9]: True

In [12]: a.isalnum() ### to check if the characters in the string are alphanumeric, if not(i.e has spaces, special characters shows flase)

Out[12]: False

In [19]: b='314'
In [20]: b.isnumeric()

Out[20]: True

You might also like