19AI301 - QR - ODD-JR Jan 2025 Exam
19AI301 - QR - ODD-JR Jan 2025 Exam
I SEMESTER
(PART A – 2 Marks)
UNIT - I
1. List any four operators in python programming with example.
2. Predict the output for the following code snippet
string1 = "Engineering College"
print("g" in string1)
print("a" in string1)
3. What are the rules for writing an identifier?
4. List the literal collections available in python with an example
5. Predict the output for the following code.
b = [21, 22, 23, 24, 25]
print(22 in b)
print(30 in b)
6. List different types of formal arguments in function
7. Predict the output for the following code snippet
x = 10.0//5
print(type(x))
8. List any 4 features of python programming.
PART B & C
1. i). Construct a python program to get the student rollno, name, department, three subject marks from the user and
find the total marks obtained. Display the student details along with the total marks.
ii). Develop a python program to find the area and perimeter of a circle.
2. i). Develop a python program to get the details from the user such as student name, age, address and CGPA and
display them.
ii). Build a python program to get the principal, rate and time from the user and find the simple interest for it.
3. i). Develop a python program to get the details from the user such as employee name, age, address and designation,
salary and display them.
ii). A 75m long train is running at 54 km/hr. Build a python program to find the time taken to cross an electric pole?
5. Describe the four types of formal arguments in function with examples for each arguments
6. i). Write a Python program to check whether a given number is a Perfect Number or not (A Perfect Number is a
positive integer that is equal to the sum of its proper divisors, excluding itself).
ii). Write a Python program to convert a given time in hours and minutes to total seconds.
i.)Write a python program to read two integers and perform simple arithmetic calculation.(+,-,*,/,//,%,**)
7. ii.) Write a python program to evaluate the following expression
a+b*c-a/b
i). Write a Python program to collect and display book details. The program should prompt the user for the book's
8. title, author, publication year, and price, then print these details.
ii). Create a Python program that takes the base and height of a triangle from the user and calculates the area of the
triangle. Display the result to the user.
Create a Python program to perform basic mathematical calculations using the following user-defined functions:
9.
1. calculate_circle_circumference(radius) to compute the circumference of a circle.
2. calculate_rectangle_perimeter(length, width) to compute the perimeter of a rectangle.
3. calculate_triangle_perimeter(side1, side2, side3) to compute the perimeter of a triangle.
4. calculate_square_perimeter(side) to compute the perimeter of a square.
10. i).Write a program in Python to input a list of numbers from the user and display only those numbers which are
divisible by 3 but not by 5.
ii).Write the definition of a method COUNTNOW(PLACES) to find and display those place names, in which there
are more than 7 characters. For example: If the list PLACES contains
["SYDNEY","TOKYO","PINKCITY","BEIJING","SUNCITY"]
UNIT - II
1. Write a Python program to print the first 20 odd numbers using a for loop
2. Write a Python program to multiply two numbers using an anonymous function.
Find the error in the following code:
3.
list = [1, 2, 3, 4, 5]
list[5] = 6
print(list)
5. Write a Python program to compute the product of all elements in a list of integers using the reduce function.
6. Write a Python program to compute the product of all numbers in a list using an anonymous function and the
‘reduce’ function from the ‘functools’
8. Write a python program to print the values from 10 to 20 numbers in reverse using a while loop
PART B & C
1. (i) Write a python program that counts the occurrence of a character in a string. Do not use built-in count function.
(ii) Write a python program to reverse the given input using iteration.
(ii) A video library rents new videos for Rs. 85 a day, and old movies for Rs 50 a day. Write a python program to
calculate the total charge for a customer’s video rentals. The program should prompt the user for the number of each
type of video and the number of days to be rented. Output the total cost.
(iii) Write a python program to print the Fibonacci series using a recursive function.
3. i. Write a Python program to check whether two entered strings are anagrams of each other (An anagram is
a word or phrase formed by rearranging the letters of another).
ii. Write a Python program to calculate the sum of the digits of a given number after reversing it.
4. (i) Write a Python function to find the greatest common divisor (GCD) of two numbers using a recursive function..
(ii) Write a Python function to calculate the monthly payment on a loan. Suppose the customer is a veteran, they are
being offered a discount rate of 3 percent; for all other customers the rate is 5 percent
(iii) Write a Python program to compute the sum of the first n natural numbers without using recursion
5. (i) Write a Python program to check whether a number is a palindrome or not using functions.
(ii) Write a program to gather individual's details such as name, age, and monthly income, and determine if the
person is eligible for a housing loan. Eligibility criteria: age between 25 to 50 years and monthly income more than
30000
(iii) Write a Python program using a function to find the sum of the first ‘n’ multiples of 5 and print the result.
ii) Write a python function to calculate simple interest. Suppose the customer is a senior citizen, he is being offered a
10 percent rate of interest; for all other customers the rate of interest is 8 percent.
(iii) Write a python program to calculate the factorial of a number without recursion function.
8. (i) Write a python program to find whether a number is prime number or composite number using functions
(ii) Nearing the election, the government employees are asked to get the individual's details such as name, age,
gender, and address and find whether the person is eligible for voting during the election. Write a program to help
the employees to find eligible persons.
(iii) Write a python program using function to find the sum of first ‘n’ even numbers and print the result
Write a Python program to calculate the taxi fare for a ride-sharing service. Consider the following fare rates:
9. ● For distances up to 5 km: Rs 15.00 per km.
● For distances more than 5 km but up to 10 km: Rs 12.00 per km.
● For distances more than 10 km but up to 20 km: Rs 10.00 per km.
● For distances more than 20 km: Rs 8.00 per km, with an additional long-distance fee of Rs 50.00.
Additional charges:
● For peak hours (6 AM to 9 AM and 5 PM to 8 PM): Rs 50.00.
● For premium service (luxury vehicles): Rs 100.00.
10. i). Write a python Program to enter the number and print the Floyd’s Triangle in decreasing order.
ii). Write a python program to find whether a given number is perfect or not.
UNIT - III
5. What is the difference between shallow copy and deep copy operations performed on lists?
6. Develop a Python program to check whether the given number is a multiple of 5 using list comprehension.
7. Develop a program to count and print the number of occurrences of each character in the message using dictionary.
ii) Write a python program to create a list of numbers in the range 1 to 10. Then delete all the even numbers from
the list and print the list with odd numbers.
iii) Write a python program to find the sum and mean of the elements in a list.
Sample input:[(10,20,40),(40,50,60),(70,80,90)]
Sample output:[(10,20,100),(40,50,100),(70,80,100)]
ii) Write a python program to return only negative values from the tuples of positive and negative numbers.
4. i) Write a python program to return the highest and lowest marks using tuples
ii) Write a python program that scans an email address and forms a tuple of user name and domain.
iii) Write a python program to return only positive values from the tuples of positive and negative numbers.
5. Write a Python program to get details of 3 employees such as employee ID, name, department, blood group, and
monthly salary, and store them in a list. Display the employee names whose salary is between 40,000 and 50,000.
Add a bonus of 5,000 to their salary and display the updated salary with their names. Also, display the employees
whose blood group is "B+".
6. i) Kritika was asked to accept a list of even numbers but she did not put the relevant condition while accepting the
list. Write a user-defined function oddtoeven(L) that accepts the List L as an argument and converts all the odd
numbers into even by multiplying them by 2.
ii) Consider the following unsorted list: 95, 79, 19, 43, 52, 3. Write the passes of bubble sort for sorting the list in
ascending order till the 4th iteration.
7. Write a Python program to get the details of employees, including their ID, name, department, and salary, from the
user and display it. Then, change the department for all employees to "Human Resources" and add the company
name to the employee details.
8. i)Write a python program to get 3 students’ details such as student register no, name, department, blood group,
English marks and store them as a list of dictionaries. Display the student name who scores the marks between 47
and 49. Add extra marks 3 and display the updated marks with the student’s name. Also, display the students whose
blood group is "B+"
i). Define a Python function filter_even_numbers(list) that takes a list of integers and removes all odd numbers
10. from the list, keeping only the even ones.
ii). Write a Python function median_and_range(list) that takes a list of integers and returns a list [median,
range], where median is the median of the numbers in the list and range is the difference between the maximum
and minimum values in the list.
UNIT - IV
1 Mention the significance of ‘sys’ module. List out its main features including ‘sys.argv’ variable
What is the role of the __init__ method in a Python class? Provide an example to illustrate its usage.
2
PART B & C
1 (i) Write a python program to create a text file “MyFile.txt” and ask the user to write separate 3 lines with
three input statements from the user.
(ii) Write a python program to find the total occurrences of a specific word from a text file.
2 (i) Write a python program with class Account, to deposit or withdraw money in a bank account.
(ii) Write a python program that counts the number of tabs, spaces and newline characters in a file.
3 (i) Write a Python program to know the cursor position and print the text according to below-given specifications:
1. Print the initial position
2. Move the cursor to 4th position
3. Display next 5 characters
4. Move the cursor to the next 10 characters
5. Print the current cursor position
6. Print next 10 characters from the current cursor position
(ii) Write a python program that uses class to store and display the employee's name and salary and print the total
employee count whose details are available.
4 (i) Write a number game program. Ask the user to enter a number. If the number is greater than the number to be
guessed, raise a ValueTooLarge exception. If the value is smaller than the number to be guessed then, raise a
ValueTooSmall exception and prompt the user to enter again. Quit the program when the user enters the correct
number.
(ii) Write a program which infinitely prints natural numbers. Raise the StopIteration exception after displaying the
first 20 numbers to exit from the program.
(iii) Write a python program to Replace all spaces from text with – (dash) in a text file.
5 Provide a detailed explanation, along with examples, on the steps involved in opening, closing, reading, and
writing to a file using Python.
6 (i) Implement a Python program using a class named "BankAccount" to manage account transactions. Include
methods for deposit, withdrawal, and display of the account balance.
(ii) Create a Python program that uses a class to store and display employee information, including name and
salary. Print the total count of employees whose details are available.
i) What are modules? Give an example of module creation and importing in Python.
7 ii) Write a small Python program to illustrate the use of try, except, and finally statements.
(i) Write a Python program to count the total number of vowels, consonants, and special characters used in the text
9 file “data.txt”.
(ii) Write a program to count the total number of words in a file and count the number of words starting with ‘a’,
‘e’, and ‘i’.
10 (i) Develop a Python program to manage a library system using classes to perform the following task.
1. Implement a class named 'Book' that keeps a record of book code, title, price and availability.
2. Display a menu to the user with all available books and prompt them to enter the book code and quantity
required.
(ii) Create a Python program for a language learning app and perform the following
1. Create a language learning app using two files - 'Vocabulary.txt' and 'Answers.txt'.
2. Read a vocabulary word from 'Vocabulary.txt' and display it with options to the user.
UNIT - V
Write a Pandas program to find the common elements between two given series.
2
3 Develop a python program to find the Eigen values and Eigen Vector of a matrix
(PART B and C)
1 Develop a Pandas program to split the following given DataFrame into groups based on school code and class. Also
split the following DataFrame into groups based on class and create a list of names for each group.
Original DataFrame:
school_code class name date_Of_Birth age
S1 s001 V Alberto Franco 15/05/2002 12
S2 s002 V Gino Mcneill 17/05/2002 12
S3 s003 VI Ryan Parkes 16/02/1999 13
S4 s001 VI Eesha Hinton 25/09/1998 13
S5 s002 V Gino Mcneill 11/05/2002 14
S6 s004 VI David Parkes 15/09/1997 12
2 Develop a Pandas program to append a list of dictionaries to an existing DataFrame and display the combined data.
Also display the Employee of the Month’s name with the highest salary.
Dictionary:
]
3 Develop a Python program to analyze data from the CSV file 'sales_data.csv' and perform the following task.
1. Read the CSV file 'sales_data.csv'. (2)
2. Display the first 5 rows of the data. (2)
3. Display the last 10 rows of the data. (3)
4. Find the number of rows in the file. (3)
5. Find the number of columns in the file. (3)
4 Develop a Pandas program to modify a DataFrame named ‘employee_data’ with the following specifications:
employee_data = {'name': ['Alice', 'Bob', 'Charlie', 'David', 'Emma', 'Frank', 'Grace', 'Hank', 'Ivy', 'Jack'],
'salary': [75000, 60000, 80000, np.nan, 55000, 95000, 72000, np.nan, 50000, 88000],
'experience': [2, 4, 3, 5, 2, 6, 3, 1, 2, 4],
'qualified': ['yes', 'no', 'yes', 'no', 'yes', 'yes', 'no', 'no', 'no', 'yes']}
labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
Perform
1. Replace the 'qualified' column with True for 'yes' and False for 'no'. (2)
3. How would you handle missing values in the 'salary' column? (3)
4. How can you check for duplicate entries in the DataFrame and remove them if any are found? (3)
5. Explain how you would save the modified DataFrame to a CSV file and load it back into a new DataFrame. (3)
5 (i) Develop a Python program to read and analyze data from a JSON file named 'employee_data.json'. Perform the
following task:
(ii) Write a Pandas program to calculate the sum of all the multiples of 3 or 5 below 100.
6 (i) Develop a python program to read all the information from the csv file ‘nba.csv’ and
a. First 5 rows
b. Last 10 rows
(ii) Write a NumPy program to insert a new axis within a 2-D array.2-D array of shape (5,
3).
a. (5, 1, 3).
b. (5, 3, 1)
c. (1, 5, 3)
7 (i).Write a Pandas program to split the following dataframe into groups based on customer id and create a list of order
date for each group.
(ii). Write a NumPy program to add a vector to each row of a given matrix.
(i) Write a Pandas program to count the number of missing values in each column of a given DataFrame.
8
ord_no purch_amt ord_date customer_id salesman_id
(ii)Write a Pandas program to join the two dataframes with matching records from both sides where available.
data1:
key1 key2 P Q
0 K0 K0 P0 Q0
1 K0 K1 P1 Q1
2 K1 K0 P2 Q2
3 K2 K1 P3 Q3
data2:
key1 key2 R S
0 K0 K0 R0 S0
1 K1 K0 R1 S1
2 K1 K0 R2 S2
3 K2 K0 R3 S3
9. Develop a Pandas program to analyze employee data with the following specifications:
employee_data = {'name': ['Alice', 'Bob', 'Charlie', 'David', 'Emma', 'Frank', 'Grace', 'Hank', 'Ivy', 'Jack'],
'salary': [75000, 60000, 80000, np.nan, 55000, 95000, 72000, np.nan, 50000, 88000],
'daycount': [1, 3, 2, 3, 2, 3, 1, 1, 2, 1],
'eligibility': ['yes', 'no', 'yes', 'no', 'no', 'yes', 'yes', 'no', 'no', 'yes']}
labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
i). Select the rows where the daycount is less than 2 and salary is greater than 60000.
i) Merge two dataframes to display only the records with matching keys from both dataframes.
ii) Merge two dataframes using keys from the left dataframe only, keeping all records from the left.
iii) Merge two dataframes using keys from the right dataframe only, keeping all records from the right.
employee_data1:
employee_data2: