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

Program 1

The document contains multiple Python programs demonstrating various data types, arithmetic operations, string manipulation, list operations, tuple usage, and dictionary handling. Each program includes code snippets and their respective outputs. The examples illustrate fundamental programming concepts in Python.

Uploaded by

haryyjazz2004
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)
7 views7 pages

Program 1

The document contains multiple Python programs demonstrating various data types, arithmetic operations, string manipulation, list operations, tuple usage, and dictionary handling. Each program includes code snippets and their respective outputs. The examples illustrate fundamental programming concepts in Python.

Uploaded by

haryyjazz2004
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

2332988 BTAIML503-20

Program 1: Write a program to demonstrate different


number data types in Python.

Code:
num1 = 25

print("Value:", num1, "| Type:", type(num1))

num2 = 3.75

print("Value:", num2, "| Type:", type(num2))

num3 = 4 + 5j

print("Value:", num3, "| Type:", type(num3))

Output:
2332988 BTAIML503-20

Program 2: Write a program to perform different Arithmetic


Operations on
Numbers

Code:
a= 15

b=4

print("Addition:", a + b)

print("Subtraction:", a-b)

print("Multiplication:", a * b)

print("Division:", a / b)

print("Modulus:", a % b)

print("Floor Division:", a // b)

Output:
2332988 BTAIML503-20

Program 3: Write a program to create, concatenate and print


a string and accessing substring from a given
string.

Code:
str1 = "Welcome"

str2 = "Home"

combined_text = str1 + " " + str2

print("Concatenated String:", combined_text)

print("Substring (first 7 characters):", combined_text[0:7])

Output:
2332988 BTAIML503-20

Program 5: Write a program to create, append, and remove


lists in python.

Code:
alphabets = ['A', 'B', 'C', 'D']

print("Original list:", alphabets)

[Link]('E')

print("After append:", alphabets)

[Link]('B')

print("After remove:", alphabets)

Output:
2332988 BTAIML503-20

Program 6: Write a program to demonstrate working with


tuples in python.

Code:
fruits = ("apple", "banana", "cherry")

print("Full tuple:", fruits)

print("First item:", fruits[0])


print("Last item:", fruits[-1])

print("Slice (first two items):", fruits[0:2])

Output:
2332988 BTAIML503-20

Program 7: Write a program to demonstrate working with


dictionaries in python.

Code:
student = {"name": "Vishal", "age": 21}

print("Name:", student["name"])

student["course"] = "Python"

new_student = {}
for key in student:
if key != "age":
new_student[key] = student[key]

print("Updated dictionary:", new_student)

Output:
2332988 BTAIML503-20

You might also like