100% found this document useful (1 vote)
97 views13 pages

Python Practical 180

The document contains a Python practical index for a course with 21 programming problems. It lists the problems, provides space for students to sign after completing each problem, and includes sample code solutions for 3 of the problems to demonstrate expected output formats. The problems cover topics like lists, strings, conditional statements, functions and involve tasks like sorting data, calculating sums and percentages, checking number properties, and counting characters.

Uploaded by

Ranveer Bodhale
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
100% found this document useful (1 vote)
97 views13 pages

Python Practical 180

The document contains a Python practical index for a course with 21 programming problems. It lists the problems, provides space for students to sign after completing each problem, and includes sample code solutions for 3 of the problems to demonstrate expected output formats. The problems cover topics like lists, strings, conditional statements, functions and involve tasks like sorting data, calculating sums and percentages, checking number properties, and counting characters.

Uploaded by

Ranveer Bodhale
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 13

Dr. D. Y.

Patil Pratishthan’s
D. Y. Patil Institute of Master of Computer Applications & Management
Sector No.29, Behind Akurdi Railway Station, Pradhikaran, Nigdi, Pune – 411044
Tel No: 020-27640998, 202737393, Fax no: 27653054,
Website: www.dypimca.ac.in, Email: [email protected]
(Approved by AICTE, Recognized by DTE, Mah.; Affiliated to SPPU)

Part A Python Practical Index

SR NO Program Date Sign


1 Write a python program for the following-
i)Create list of fruits ii)Add new
fruit in list iii)sort the list
iv)delete last fruit name from list.

2 Write a program to create new list ‘b’ which contains only initial
letters from given list
A=[‘Pune’,’Mumbai’,’Delhi’,’Nagpur’]
3 Write a program to print different vowels present in the word
"Learning python"?
4 Write a program to check whether the given number is even or odd?
5 Write a program to find maximum of 3 numbers using ternary
operator.
6 Write a program to display student score card with Student name,
No. of subjects, total , percentage, and grade.
7 Write a program to display student score card with Student name,
No. of subjects, total , percentage, and grade.
8 Write a program to print odd numbers between 0 to 100 using
continue statement
9 Write a program to take user inputs for list, set, tuple and dictionary
and display using for loop.
10 Write a program to add 10 employee names into list using for loop and
display list: append() or insert(index, value)
11 Write a program to print sum of numbers present inside list.
12 Write a program to check whether entered number is prime or not
13 Write a program to create list for basic salary of employee and
calculate the gross salary of an employee for following allowance
and deduction.
DA=25% , HRA=15%, PF=12%,TA=7,50%
Net Pay=basic+DA+HRA+TA
Gross Pay=Net Pay-PF
14 Write a program to access each character of string in forward and
backward direction using while loop.
15 Write a program to reverse the given string.

Eg. I/P: dyp o/p:


pyd

16 Write a program to reverse order of word.


Eg. I/P: Learning python is very easy o/p:easy
very is python Learning

17 Write a program that accept the string from user and display the
same string after removing vowels from it.

18 Write a program to sort the characters of the string and first alphabet
symbols followed by numeric values.
input: B4A1D3
Output: ABD134
19 Write a program to find the number of occurrences of each character
present in the given String?
input: ABCABCABBCDE
output: A-3,B-4,C-3,D-1,E-1

20 Write a python program to calculate of percentage of the given


list of marks using Arbitrary argument.
21 Write a Python function that accepts a string and counts the number
of upper and lower case letters. Eg: “Data Is Very
Important”
1. Write a python program for the following

i)Create list of fruits


ii)Add new fruit in list
iii)sort the list
iv)delete last fruit name from ist.
# i) Create list of fruits fruits =
['apple', 'banana', 'orange']
print(fruits)
# ii) Add new fruit in list
fruits.append('grape')
print(fruits) # iii) Sort
the list fruits.sort()
print(fruits)
# iv) Delete last fruit name from list del
fruits[-1]

Output –

2. Write a program to create new list ‘b’ which contains only initial letters from
given list A=[‘Pune’,’Mumbai’,’Delhi’,’Nagpur’]

A = ['Pune', 'Mumbai', 'Delhi', 'Nagpur']


b = [word[0] for word in A] print(b)
Output –
3. Write a program to print different vowels present in the word "Learning
python"?

word = "Learning python"


vowels = {char for char in word if char.lower() in 'aeiou'}
print(vowels)

Output –

4. Write a program to check whether the given number is even or odd?

num = int(input("Enter a number: ")) result


= "Even" if num % 2 == 0 else "Odd"
print(result)

Output –
5. Write a program to find maximum of 3 numbers using ternary operator. a, b,
c = 10, 20, 30

max_num = a if (a > b and a > c) else (b if b > c else c) print(max_num)

Output –

6. Write a program to display student score card with Student name, No. of
subjects, total , percentage, and grade.

student_name = "John"
num_subjects = 5 marks =
[85, 90, 78, 92, 88]
total_marks = sum(marks)
percentage = total_marks / (num_subjects * 100) * 100 grade = 'A'
if percentage >= 80 else 'B' if percentage >= 60 else 'C'
print(f"Name: {student_name}") print(f"No.
of subjects: {num_subjects}") print(f"Total
marks: {total_marks}") print(f"Percentage:
{percentage}%") print(f"Grade: {grade}")

Output –
7. Write a program to print odd numbers between 0 to 100 using continue
statement

for i in range(101):
if i % 2 == 0:
continue
print(i, end=' ')

Output –

8. Write a program to take user inputs for list, set, tuple and dictionary and
display using for loop.
# List

user_list = input("Enter elements of list separated by space: ").split()


print("List:", user_list)

# Set
user_set = set(input("Enter elements of set separated by space: ").split())
print("Set:", user_set)

# Tuple
user_tuple = tuple(input("Enter elements of tuple separated by space:
").split()) print("Tuple:", user_tuple)

#Dictionary
user_dict =
{} while
True:
key = input("Enter key (or 'quit' to stop): ")
if key == 'quit':
break value =
input("Enter value: ")
user_dict[key] = value
print("Dictionary:", user_dict)

Output –

9. Write a program to add 10 employee names into list using for loop and
display list: append() or insert(index, value)

employee_names = [] for _ in range(10):


name = input("Enter employee name: ")
employee_names.append(name)
print("Employee names:", employee_names)

Output –
10. Write a program to print sum of numbers present inside list.

def sum_of_numbers(num_list):
total = 0
for num in num_list:
if isinstance(num, (int, float)):
total += num
return total

# Example usage:
numbers = [10, 20, 30, 40, 50]
print("Sum of numbers:", sum_of_numbers(numbers))

11. Write a program to check whether entered number is prime or not

def is_prime(num): if num <= 1:


return False for i in range(2, int(num
** 0.5) + 1): if num % i == 0:
return False
return True
num = int(input("Enter a number: ")) if is_prime(num):
print("Prime")
else:
print("Not prime")

Output –
12. Write a program to create list for basic salary of employee and calculate the
gross salary of an employee for following allowance and deduction.

DA=25% , HRA=15%, PF=12%,TA=7,50%


Net Pay=basic+DA+HRA+TA
Gross Pay=Net Pay-PF

basic_salary = float(input("Enter basic salary: "))


DA = 0.25 * basic_salary
HRA = 0.15 * basic_salary
TA = 7.50
PF = 0.12 * basic_salary

net_pay = basic_salary + DA + HRA + TA gross_pay


= net_pay - PF

print("Gross salary:", gross_pay)

Output –

13. Write a program to access each character of string in forward and


backward direction using while loop

string = input("Enter a string: ") print("Forward direction:") index = 0 while index


< len(string):

print(string[index], end=" ")

index += 1
print("\nBackward direction:")

index = len(string) - 1 while

index >= 0:

print(string[index], end=" ")

index -= 1

Output –

14. Write a program to reverse the given string.

Eg. I/P: dyp


o/p: pyd

string = input("Enter a string: ") print("Reversed


string:", string[::-1])
Output –
15. Write a program to reverse order of word.

Eg. I/P: Learning python is very easy


o/p:easy very is python Learning

string = input("Enter a string: ") words =


string.split() reversed_string = '
'.join(reversed(words))
print("Reversed order of words:", reversed_string)

Output –

16. Write a program that accept the string from user and display the same
string after removing vowels from it.

string = input("Enter a string: ") vowels


= 'aeiouAEIOU'
string_without_vowels = ''.join(char for char in string if char not in vowels)
print("String without vowels:", string_without_vowels)

Output –
17. Write a program to sort the characters of the string and first alphabet
symbols followed by numeric values.
input: B4A1D3
Output: ABD134

input_string = "B4A1D3"
alphabets = ''.join(sorted(char for char in input_string if char.isalpha())) numbers
= ''.join(sorted(char for char in input_string if char.isdigit()))
output_string = alphabets + numbers
print("Sorted output:", output_string)

Output –

18. Write a program to find the number of occurrences of each character


present in the given String?

input: ABCABCABBCDE
output: A-3,B-4,C-3,D-1,E-1
input_string = "ABCABCABBCDE"
char_count = {} for char in input_string:
char_count[char] = char_count.get(char, 0) + 1
for char, count in char_count.items():
print(f"{char}-{count}", end=", ")

Output –
19. Write a python program to calculate of percentage of the given list of
marks using Arbitrary argument

def calculate_percentage(*marks): total_marks =


sum(marks) percentage = (total_marks / (len(marks)
* 100)) * 100 return percentage

marks_list = [85, 90, 75, 80]


print("Percentage:", calculate_percentage(*marks_list))

Output –

20. Write a Python function that accepts a string and counts the number of
upper and lower case letters. Eg: “Data Is Very Important”

def count_upper_lower(string): upper_count = sum(1


for char in string if char.isupper()) lower_count = sum(1
for char in string if char.islower()) return upper_count,
lower_count
input_string = "Data Is Very Important" upper,
lower = count_upper_lower(input_string)
print("Number of uppercase letters:", upper)
print("Number of lowercase letters:", lower)
Output –

You might also like