0% found this document useful (0 votes)
5 views5 pages

Python Programming Practical Tasks

The document outlines practical programming tasks involving conditional and iterative programming, lists, tuples, dictionaries, and string methods. It includes examples for finding the largest of three numbers, checking even or odd numbers, and calculating sums, as well as operations on lists and dictionaries. Additionally, it covers string manipulation techniques such as converting case, finding substrings, and splitting strings.

Uploaded by

debasishgoudads
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)
5 views5 pages

Python Programming Practical Tasks

The document outlines practical programming tasks involving conditional and iterative programming, lists, tuples, dictionaries, and string methods. It includes examples for finding the largest of three numbers, checking even or odd numbers, and calculating sums, as well as operations on lists and dictionaries. Additionally, it covers string manipulation techniques such as converting case, finding substrings, and splitting strings.

Uploaded by

debasishgoudads
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

Activity / Practical File

Part A: Conditional Programming and Iterative Programming

Task 1: Find the Largest of Three Numbers

a = int(input('Enter first number: '))

b = int(input('Enter second number: '))

c = int(input('Enter third number: '))

if a > b and a > c:

print('Largest number is:', a)

elif b > c:

print('Largest number is:', b)

else:

print('Largest number is:', c)

Task 2: Check if a Number is Even or Odd

num = int(input('Enter a number: '))

if num % 2 == 0:

print('Even number')

else:

print('Odd number')

Task 3: Print Numbers from 1 to 10 using a For Loop

for i in range(1, 11):

print(i, end=' ')

Task 4: Sum of First N Natural Numbers using While Loop


Activity / Practical File

n = int(input('Enter a number: '))

sum = 0

i=1

while i <= n:

sum += i

i += 1

print('Sum =', sum)

Task 5: Grade Calculator using Nested Conditions

marks = int(input('Enter your marks: '))

if marks >= 90:

print('Grade: A')

elif marks >= 80:

print('Grade: B')

elif marks >= 70:

print('Grade: C')

elif marks >= 60:

print('Grade: D')

else:

print('Grade: F')

Part B: Lists, Tuples, and Dictionary

Task 1: Create a List and Print All Elements

fruits = ['apple', 'banana', 'cherry', 'date']


Activity / Practical File

for fruit in fruits:

print(fruit)

Task 2: Tuple Operations - Access Elements

colors = ('red', 'green', 'blue', 'yellow')

print('First color:', colors[0])

print('Last color:', colors[-1])

Task 3: Add and Remove Elements from a List

numbers = [1, 2, 3, 4, 5]

[Link](6)

print('After append:', numbers)

[Link](3)

print('After remove:', numbers)

Task 4: Create and Access Dictionary Elements

student = {'name': 'Alice', 'age': 20, 'grade': 'A'}

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

print('Age:', student['age'])

Task 5: Dictionary - Add and Delete Keys

employee = {'name': 'John', 'department': 'Sales'}

employee['salary'] = 50000

print('Updated Dictionary:', employee)


Activity / Practical File

del employee['department']

print('After Deletion:', employee)

Part C: String Methods

Task 1: Convert a String to Upper and Lower Case

text = 'Hello World'

print([Link]())

print([Link]())

Task 2: Find the Position of a Substring

sentence = 'Python is a powerful language.'

pos = [Link]('powerful')

print('Position of powerful:', pos)

Task 3: Replace a Word in a String

sentence = 'I like Java.'

new_sentence = [Link]('Java', 'Python')

print(new_sentence)

Task 4: Check if a String is Alphanumeric

string1 = 'Python123'

print([Link]())

Task 5: Split a String Based on a Delimiter


Activity / Practical File

data = 'apple,banana,grape'

fruits = [Link](',')

print(fruits)

You might also like