0% found this document useful (0 votes)
3 views

Python Paper

The document contains a series of programming tasks that require writing Python programs for various operations, such as reversing words in a sentence, finding the longest name in a list, calculating average age from a dictionary, and more. Each task is presented as a specific input-output requirement, covering a wide range of topics including string manipulation, list processing, and data structure handling. The tasks are designed to test and enhance Python programming skills.

Uploaded by

jagdishdapke362
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)
3 views

Python Paper

The document contains a series of programming tasks that require writing Python programs for various operations, such as reversing words in a sentence, finding the longest name in a list, calculating average age from a dictionary, and more. Each task is presented as a specific input-output requirement, covering a wide range of topics including string manipulation, list processing, and data structure handling. The tasks are designed to test and enhance Python programming skills.

Uploaded by

jagdishdapke362
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/ 3

1. You have a string containing a sentence. Write a Python program to reverse the words in the sentence.

2. You have a list of names. Write a Python program to find the length of the longest name in the list.
3. You have a dictionary containing the names and ages of people. Write a Python program to find the average age
of all the people in the dictionary.
4. You have a list of strings. Write a Python program to find the shortest string in the list.
5. You have a list of tuples, where each tuple contains the name and age of a person. Write a Python program to
find the oldest person in the list
6. You have a dictionary containing the names and ages of people. Write a Python program to print the names of all
the people who are older than 18.
7. You are given two numbers, a and b. Write a Python program to swap the values of a and b without using a
temporary variable.
8. You have a string. Write a Python program to count the number of occurrences of a specific character in the
string.
9. You have a list of integers. Write a Python program to remove all the duplicates from the list and create a new
list with unique elements only.
10. You have a string containing a sentence. Write a Python program to convert the sentence into title case, where
the first letter of each word is capitalized.
11. You have a list of dictionaries, each containing information about a person (e.g., name, age, city). Write a
Python program to sort the list of dictionaries by age in ascending order.
12. You have two dictionaries representing the sales data of two different stores, with product names as keys and
sales amounts as values. Write a Python program to merge the two dictionaries and calculate the total sales amount
for each product across both stores.
13. You have a tuple of numbers. Write a Python program to find the maximum and minimum values in the tuple,
and calculate their difference.
14. You are building a car rental system. Write a Python program to create a Car class with attributes such as make,
model, and year, and methods to get and set these attributes.
15. You are building an e-commerce website. Write a Python program to create a Product class with attributes such
as name, price, and quantity, and methods to calculate the total cost of the product based on its price and quantity.
16. Consider the given list try to get an output where first element on each sub-list is in reversed order
I/P : [[1,2,3,4],[5,6,7,8],[9,10,11,12][13,14,15,15]]
O/P:[[13,2,3,4],[9,6,7,8],[5,10,11,12],[1,14,15,16]]

17. You have a string in Python. Write a program to count the number of vowels in the string.
18. You have a list of strings in Python. Write a program to find the longest string in the list.
19. You have a dictionary in Python that contains student names as keys and their corresponding scores as values.
Write a program to find the student with the highest score.
20. You have a list of names in Python. Write a program to sort the names in alphabetical order.
21. You have a list of numbers in Python. Write a program to find the largest and smallest numbers in the list.
22. You have a list of names and you need to create a new list containing only the names that start with a specific
letter.
23. You have a string and you need to count the occurrences of each character in the string.
24. You have a dictionary containing student names and their corresponding scores. You need to find the student
with the highest score.
25. Write a Python program to count the occurrences of each word in a given string.

26. l1=[1,2,3]
l2=[2,3,4]
oup:[3,5,7]

27. i/p a=[1,2,3],b=[‘a’,’b’,’c’]


o/p {1:’a’,2:’b’,3:’c’}

28. a = 'Team Brainwroks' collect vowels from above string in list

29. Write a program for given Input and produce the following output
I/p: str = 'aaaabbbcc' o/p : 432

30. Write a program to find Second Max Value


li = [10,20,4,45,88]
o/p : 45

31. Find occurrence of each character.


Lis=[‘malyalum’]

32. Write a program to Count No. of occurrences of character in a given string using dictionary
comprehension.(str=”I love My India”)

33. Write a program for below a=[3a,4b,5c,1d] expected o\p aaabbbbcccccd


34. Only digits reverse
str1 = "123$4456%7489*0^"
op=098$4765%4432*1^

35. Input ="Sachin Ramesh Tendulkar"


output=S. R. Tendulkar

36. Write program for descending order without inbuild fun.


Input=[700,234,574,1,34,31,22]

37. Count max number of character


s="madhuriiimadhrammaaaammmmr"

38. input='A3G4B2'
output= 'ADGKBD'

39. Write a python program for string that will print out char with char count.E.g. c Output should be a4b1a1h5
str1= 'aaaabahhhhhaaa'

40. s='4555&.$@abc'
op=4555

41. s= "name=Dattatray&surname=Tompe&occ=coder"
Output ={'name':'Dattatray' , 'surname':'Tompe' , 'occ':'coder'}

42. Reverse 312 to 213 without converting it into str.

43. a = [ {'name': 'a1' }, {'name': 'a2' }, {'name': 'a3' }, {'name': 'a4' }, {'name': 'a5' } ]
b = [ { 'name': 'a3' }, {'name': 'a5' } ]
O/P: [{'name': 'a3'}, {'name': 'a5'}, {'name': 'a1'}, {'name': 'a2'}, {'name': 'a4'}]

44. Write a Python program to find all the words in the given list whose length is between 5 and 7.
words = *'This', 'is', 'a', 'list', 'of', 'words', 'that', 'contains', 'some', 'technical', 'jargon', 'and', 'abbreviations'+

45. Write a Python program using regular expression to check whether the given string is following below
requirement or not.
I. The allowed characters are a z, A Z, 0 9,#
II. The first character should be a lower case alphabet symbol from a to k
III. The second character should be a digit divisible by 3.
IV. The length of the identifier should be at least 2.

46. Write a Python program to add two number using decorator

47. Find the second highest element from given list.


L=[48,89,65,78,95,26,1,45,95]

48. s1 = [3, 4, 5, 6, 0]
s2 = [9, 5, 6, 1, 8]
o/p = {(4, 5), (0, 9), (3, 6)}

50. IP L=[0,1,1,0,0,1,1,1,0,1,0,1,0] o/p [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1]

You might also like