Python Slips
Python Slips
Lab Course II
Slip 1
Q2.Write a Python program to count the occurrences of given word in sentence. Accept sentence and
word from user. [ [20]
Lab Course II
Slip 2
Q2.Write a Python program to count frequency of each character in a given string using user
Lab Course II
Slip 3
Q2. Write a Python program to accept string and remove the characters which have odd index values of
a given string using user defined function. [20]
Lab Course II
Slip 4
Q1. Write a program to accept 5 numbers and calculate its Mean value [10]
Q2.Write a Python program to accept a string and from a given string where all occurrences of its first
character have been changed to '$', except the first char itself. [20]
Lab Course II
Slip 5
Q1. Write a program which reverses a string and displays both original and reversed string. [10]
Q2.Write a program to create tuple of n numbers, print the first half values of tuple in one line and the
last half values of tuple on next line. [20]
Lab Course II
Slip 6
Q1. Write a program which accepts 10 integers and prints "DUPLICATES" if any of the values entered are
duplicates otherwise prints "ALL UNIQUE". [10]
Q2. Write a Python program to create a tuple of n numbers and print maximum, minimum, and sum of
elements in a tuple. [20]
Lab Course II
Slip 7
Q2. Write a Python program to accept two lists and merge the two lists into list of tuple. [20]
Lab Course II
Slip 8
Q1. Write a program which accepts an integer value 'n' and prints all prime numbers till 'n'. [10]
Q2. Write a Python program to perform operation on sets which includes union of two sets, an
intersection of sets, set difference and a symmetric difference. [20]
Lab Course II
Slip 9
Q2. Write a Python program to accept n elements in a set and find the length of a set, maximum,
minimum value and the sum of values in a set. [20]
Lab Course II
Slip 10
Q1. Write a program to get a single string from two given strings and swap the first two characters of
each string. [10]
Q2.Write a Python program to accept n numbers in list and find sum and average of numbers in list. [20]
Lab Course II
Slip 11
Q2. Write a Python program to accept n numbers in list and remove duplicates from a list.[20]
Lab Course II
Slip 12
Q2. Write a Python script to generate and print a dictionary that contains a number (between 1
Sample Dictionary (n = 5)
Lab Course II
Slip 13
Q2. Write a Python program to accept n numbers in list and find maximum and minimum from list. [20]
Lab Course II
Slip 14
Q2. . Write a Python program to define class to find validity of a string of parentheses, '(', ')', '{', '}', '[' and
'].These brackets must be in the correct order, for example "()" and "()[]{}" are valid but "[)", "({[)]" and
"{{{" are invalid using exception. [20]
Lab Course II
Slip 15
Q1. Write a program to create a list of tuples with the first element as the number and second element
as the square of the number. [10]
Q2. Write a program to count the types of files in directory. Display the type and count.
Lab Course II
Slip 16
Q2.Write a python program to accept NxN matrix and display the same. [20]
Lab Course II
Slip 17
Q1. Write a program which checks whether an element exists within a tuple. [10]
a. Hexadecimal to Octal
b. Decimal to Octal
Lab Course II
Slip 18
Q1. Write a program to create set difference and a symmetric difference. [10]
Q2.Write python program to accept and print string in reverse order using recursion. [20]
Slip 19
Q1. Write a program to accept 10 numbers and find its median [10]
Q2. Write a Python program to check if a given key already exists in a dictionary. If key exists replace
with another key/value pair. [20]
Lab Course II
Slip 20
Q1. Write a program to accept 10 numbers and find its Mode [10]
Q2. Write python program using an anonymous function to find area of circle, circumference of circle.
[20]
Lab Course II
Slip 21
Q1. Write a program to accept a number and display its first ten multiples. [10]
Q2. Write python program to make directory, change directory, list files from directory and remove
directory. [20]
Lab Course II
Slip 22
Q1. Write a program to accept 10 numbers, display the sum of odd numbers and sum of even numbers.
[10]
Q2. Write a Python program to display all files in current directory along with size and mode of file. [20]
Lab Course II
Slip 23
Q1. Write a program to accept a number 'n', and display the following pattern (Floyd's triangle)n=3
23
4 5 6 [10]
Q2. Write python program which provides a hint to the user so that he can figure out the correct
alphabet. The program will ask the user to enter an alphabet until they guess a stored alphabet
correctly. [20]
Lab Course II
Slip 24
1234
123
12
Q2. Write python program which provides a hint to the user so that he can figure out the correct
number. The program will ask the user to enter a number until they guess a stored number correctly
using user defined exceptions. [20]
Lab Course II
Slip 25
Q1. Write a program to check whether input number is divisible by 3 or 5 or both. [10]
Q2. Write python program to find factorial of numbers using recursion. [20]
Lab Course II
Slip 26
Q1. Write a program to accept and convert string in uppercase or vice versa. [10]
Q2. Write python program using an anonymous function to find area of circle, circumference of circle.
[20]
Lab Course II
Slip 27
Q1. Write a program to create list of tuples with the first element as the number and second element as
the cube of the number. [10]
Q2. Write python program that converts a temperature from Kelvin to Fahrenheit, the function bails out
if a negative temperature is entered. [Use assertion] [20]
Lab Course II
Slip 28
Q2. Write python program to find GCD of numbers using recursion. [20]
Lab Course II
Slip 29
Q1. Write a program to perform the add and remove operations on a set. [10]
Q2. Write python program to display the Fibonacci sequence up to nth term using recursive function.
[20]
Lab Course II
Slip 30
Q2. Write a python program which will calculate the average of the values in list passed by the user and
the value should not be an empty list. If value is empty list, it should raise error. [Use Assertion] [20]