Python Programming Exam
Python Programming Exam [Time: 1 hr]
[Total Marks: 100]
Questions
Perform the following tasks: Marks
Q1. Count all letters, digits, and special symbols from a given [5]
string
str1 = "I@#ma26rt^&ic5us"
Q2. Write a Python program to find numbers divisible by
nineteen or thirteen from a list of numbers using Lambda.
a=[19, 65, 57, 39, 152, 639, 121, 44, 90, 190]
Q3. Find all of the words in a string that are less than 5 letters
string = "Practice Problems to Drill List Comprehension in
Your Head."
Q4. Calculate income tax for the given income by adhering to the
below rules
Expected Output:
For example, suppose the taxable income is 45000 the
income tax payable is
10000 0% + 10000 10% + 25000 20% = $6000.
Python Programming Exam
Q5. Given below are the list of positive and negative words. Also
a list of tweets is provided. Separate out the positive and
negative comments¶
positive = ['good','awesome', 'best', 'nice']
negative = ['worst','awful', 'bad']
tweets = ['This government policies are good', 'bad
implementation', 'The way he played showed that he is one
of the best players in the world', 'Her acting in the play was
awesome', 'The wine tastes awful', 'It's nice to hear this little
kid's laugh']
Q6. Extend nested list by adding the sublist
You have been given a nested list. Write a program to extend
it by adding the sublist ["h", "i", "j"] in such a way that it will
look like the following list.
list1 = ["a", "b", ["c", ["d", "e", ["f", "g"], "k"], "l"], "m", "n"]
sub list to add
sub_list = ["h", "i", "j"]
expected output =['a', 'b', ['c', ['d', 'e', ['f', 'g', 'h', 'i', 'j'], 'k'], 'l'],
'm', 'n']
Remove and add item in a list
Write a program to remove the item present at index 4 and
add it to the 2nd position and at the end of the list.
list1 = [54, 44, 27, 79, 91, 41]
Q7. Load the iris dataset. Find only those records whose
sepal_length = 5.1 and sepal_width = 3.5
Python Programming Exam
Check for Maximum petal_length and convert it in to 7.2 and
min petal_length and convert it in to 1.2
Q.8 Perform right join to combine values based on the 'ID' in the
two dataframes
Use the dataframe given below, Read the DataFrame with the
help of clipboard function.
ID Candidate_Name Subject
101 Alex History
102 Amy English
103 Allen Geography
104 Alice German
105 James History
106 Sara German
107 Mia English
ID City Subject_Score
101 Delhi 89
102 Mumbai 78
103 Delhi 77
104 Chennai 87
105 Hyderabad 87
108 Delhi 84