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

Integer

The document demonstrates the use of different data types in Python, including integers, floats, and complex numbers, along with their values and types. It also covers lists, tuples, and strings, showcasing how to access elements and perform slicing. The output section illustrates the results of the operations performed on these data types.

Uploaded by

suruthi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views3 pages

Integer

The document demonstrates the use of different data types in Python, including integers, floats, and complex numbers, along with their values and types. It also covers lists, tuples, and strings, showcasing how to access elements and perform slicing. The output section illustrates the results of the operations performed on these data types.

Uploaded by

suruthi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

# Integer

a = 10

print("Value of a:", a)

print("Type of a:", type(a))

# Float

b = 5.75

print("\nValue of b:", b)

print("Type of b:", type(b))

# Complex

c = 2 + 3j

print("\nValue of c:", c)

print("Type of c:", type(c))

OUTPUT

Value of a: 10

Type of a: <class 'int'>

Value of b: 5.75

Type of b: <class 'float'>

Value of c: (2+3j)

Type of c: <class 'complex'>


# List

numbers = [10, 20, 30, 40]

print("List:", numbers)

print("First element in list:", numbers[0]) # Indexing

# Tuple

values = (1, 2, 3, 4)

print("\nTuple:", values)

print("Second element in tuple:", values[1])

# String

text = "Python"

print("\nString:", text)

print("First character in string:", text[0])

# Slicing

print("\nSlicing list (1 to 3):", numbers[1:3])

print("Slicing string (0 to 4):", text[0:4])

Output
List: [10, 20, 30, 40]
First element in list: 10

Tuple: (1, 2, 3, 4)
Second element in tuple: 2

String: Python
First character in string: P

Slicing list (1 to 3): [20, 30]


Slicing string (0 to 4): Pyth

You might also like