11 CS BT2 Assignment File
11 CS BT2 Assignment File
LOOP
2) Write a program in python to display all the prime numbers in a given range of values.
a) A
BC
DEF
GHIJ
KLMNO
b) *
**
***
****
*****
4) Write the code in python to display summation of the following series:
a) s= x+ x2 + x3 +……….+ xn (value of x and n to be taken from user)
STRING
5) Write a program in Python to enter a string and print the highest occurrence of a particular
character consecutively.
Example: Enter a string: abcaaacacaaaabaaaaabbb
Output: aaaaa
6) Write a Python code to accept a name (containing three words) and display only the initials
(i.e. first letter of each word).
Sample input: LAL KRISHNA ADVANI
Sample output: L K A
7) Write a program to input a line of text and do the following:
i) Print the longest word from it.
ii) Display those words having first and last character same.
iii)Display the count of vowels in it.
8) Write a program in Python to enter a string.
i) Check whether it is palindrome or not
ii) Count and display number of digits, spaces and uppercase, lowercase letter.
LIST
13) Consider a tuple of non-zero numbers. Write a program in Python to shift the negative
numbers to right and the positive numbers to left so that the resultant list will be as follows :
Original tuple: (-2,1,-3,-15,16,-17,5,-3,-6)
Output should be: (1,16,5,-6,-3,-17,-15,-3,-2)
14) Given a tuple of pairs = ((2, 5), (4, 2), (9,8), (12,10)), count the number of pairs (a, b) such
that both a and b are even.
15) Write a program in python to enter a tuple of integers and remove all the duplicate
occurrence.
16) Write a program to input ‘n’ numbers in a tuple and separate the tuple in the following
manner.
Example
T=(10,20,30,40,50,60)
Tl=(10,30,50)
T2=(20,40,60)
DICTIONARY
17) Write a program in python to take a list of some integer values. Create a dictionary from the
list such that keys will be every elements of list and values will be cube of each element.
Example: L=[2,3,4]
D={2:8,3:27,4:64}
18) Write a python program to input the name of students with their age as key-value pairs of a
dictionary and perform the following operations:
i) Ask user to enter any name and delete that particular pair.
ii) Display only the name of every student.
19) Declare a dictionary in python whose keys are month names and values are the number of
days in the corresponding months.
i) Ask the user to enter a month name and use the dictionary to display number of days in
that particular month.
ii) Display all of the months with 31 days.
20) Write a program to take a list of numbers and perform the following task:
i) Display the number of occurrence of every number in dictionary format.
Example: l= [1, 2, 3,2,1,5,5,2]
i) d={1:2,2:3,3:1,5:2}