VIT-AP
= UNIVERSITY
Apply Knowledge. Improve Life!”
QUESTION PAPER
Name of the Examination: FALL 2023-2024 - FAT
Course Code: CSE1012 Course ‘Title: Problem solving using Python
Set number: | Date of Exam: 30/0904 Pn) (C2)
Duration: 120mins ‘Total Marks: 60
Instructions:
1. Assume data wherever necessary.
2. Any assumptions made should be clearly stated.
1. ® Write a python code with while loop and loop modification statements, where the Ser ga7_sy4)
thas to guess a secret number between I and 10. The user have only 3 attempts to guess.
‘After each attempt, the game will give hints if the correct number is higher or lower
than the guessed number. The code should stop when the user guesses right number or
uses up all the attempts,
‘Sample Input: set secret number to 4
Expected outpi
Guess the secret number between 1 and 10?
Attempt 1/3: Enter your guess: 3
Incorrect. The correct number is higher.
Attempt 2/3: Enter your guess: 1
Incorrect. The correct number is higher.
Attempt 3/3: Enter your guess: 2
Sorry, you've run out of attempts. The correct number was 4.
b) Write « Python program that takes a tuple containing temperature values in Celsius as
input. Using Python looping concepts, the program should convert each Celsius
temperature to Fabrenheit using the formula F = 2 ¢ + 32. The output should be a tuple
containing the corresponding Fahrenheit values.
‘Sample Input: Celsius Temperatures: (0, 20, 37, -5, 100)
Expected Output: Fahrenheit Values: (32, 68, 98.6, 23, 212)
Design a Python program for a personal finance tracker with recursive functionality. (gq)
Greate a User-defined module named ‘finance module’ feturing functions for
calculating total expenses, total income, and net balance. Use recursion to handle nested
Fists within expenses and income. Import this module into a main program where wsers
an input their financial data, and the program uses fonctions ftom the module to
Caloulate and print the net balance. The program should gracefully handle various
expense and income scenarios, including nested structures while providing accurate net
balance calculations.
Sample Input: Expected Output:
Expenses = [50, (30, 10,10} [10,{5, Il] Net Balance: 430
Income ~ (150, (200, (50,35, 15], 100}
Q.
4) In the context of enhancing egg analysis on a poultry farm, the task is to develop &
‘Python function named calculate _deviations(gg Sizes, Ideal Size) that not only
computes the size deviations of eggs from an ideal size but also classifies them into
three eategories: ‘Small; ‘Ideal, and ‘Large.’ The classification is based on specific
@. (10+5=15M)Qa.
rales; eggs with a deviation of less than 1 mm are categorized as ‘deal,’ those with
deviations between | mm and 2mm (inclusive) as ‘Small,’ and eggs with deviations
exceeding 2 mm as ‘Large.
Sample Input (sizes are in mm): Expected Output:
Input Egg Sizes: {3, 3.2, 2.8, 4.1, 3.8} Deviations (mm): {2.0, 1.8, 2.2,0.9, 12}
deal Size: 5 Categories: (‘Small ‘Small, ‘Large’, Ideal’ 'Small")
b) Write a Python program to sirmulate the collection of 10 random floating-point numbers
between 0 and 1, representing measurements of an experiment. Utilize the random
‘module for number generation. Apply a mathematical function to calculate the square
root of each number in the generated list, Determine and print the average of the squared
values. Identify and display the maximum and minimum values from the original lst.
‘Sample Random Input data=(0.15, 0.82, 0.37, 0.64, 0.45, 0.73, 0.28, 0.57,
0,09,0.41)
Expected Output:
Squared Values: (0.387, 0.904, 0.608, 0.8, 0.673, 0.852, 0.529, 0.755, 0.3, 0.641)
Average of Squared Values: 0.65
‘Maximum Value: 0.82
‘Minimum Value: 0.09
8) Develop a Python program that reads sentences ftom a text file (named ‘rawdatatxt’),
capitalizes the first letter of each word in a sentence, removes spaces between words,
and prepends a #' symbol to create social media handles. The program should then write
the resulting handles to a new text file (named ‘InstaHendles.txt’). For instance, given
the sample input sentence "passionate coder and tech enthusiast," the expected output
should be "#PassionateCoderAndTechEnthusiast."
b) Write @ Python program to read data from the CSV file "sample_student_data.csy,”
where each row contains student names and their respective scores. One function should
bbe a user-defined functions to compute the average score of the students and the other
function should identify the list of students with scores above the calculated average,
‘The program should then generate a new text file named “output_resultstxt" containing
the calculated average score and a list of students who scored above the average. This
approach ensures a structured and modularized code for processing student data and
deriving meaningful results.
Sample Input: (csv File) Expected Output: (xt File)
(ample student datas): (output results):
Name, Score Average Score: 86.25
Students above Average:
Madhini (92)
Guna (90)
or MAPPING
Q.No. | Module Number | CO Mapped | 47°, Marks
Mapped
a Ed 3a [Taaase[ = =
= y 3 [iasasa] TIRES
G 36 35 [iasase| = 6M
a é o[iasasa| = saaCourse Code: CSEI012
iy VIT-AP
== UNIVERSITY
Apply Knowledge. Improve Life!”
QUESTION PAPER
Name of the Examination: FALL 2023-2024 — FAT
Course Title: Problem Solving using Python
Set number: 2 Date of Exam: 02/02/7094) (Fn) Coy)
Duration: 120 mins Total Marks: 60
Instructions:
1
Assume data wherever necessary.
2. Any assumptions made should be clearly stated.
1. ® Write’ program to print twin primes less than 1000. If two consecutive (@i7-15N4)
@.
‘odd numbers are both prime then they are known as twin primes.
Input: Enter a number (range): 1000
Output:
Print twin primes less than 1000: (3, 5) (5, 7) (11, 13) (17, 19)...
b) Ifall digits of a number n are multiplied by each other repeating with
the product, the one-digit mumber obtained at last is called the
multiplicative digital root (MDR) of n. The number of times digits need
to be multiplied to reach one digit is called the multiplicative persistence
(MPersistence) of n, Implement a python program for the above
‘mechanism.
Input:
Enter a number: 86 MDR: 6, MPersistence: 3
(86 > 48 > 3296)
Enter a number: 341 MDR: 2, MPersistence:2
(3419 1292)
Write a Python program that discovers and prints pairs of "Amicable
numbers” within a specified numerical range. Amicable numbers are special
pairs where the sum of the proper divisors of each number equals the other
number ( Note: Don't use any pre-define function).
The program should include:
1, sum_of_proper_divisors functio
divisors for a number using recursion.
2, find_amicable_pairs_in_range function: Iterate through a user-
specified range and identify amicable pairs using the recursive function
sum_of_proper_divisors.
3, main function: Gather user input for the mumerical range, call
find_amicable_pairs_in_range, and print any discovered amicable pairs.
Calculate the sum of proper
Input: Output:
Enter the starting range: 200 Amicable pairs:
Enter the ending range: 300 220 and 284 are Amicable pairs.
asm)Qs, ® Develop a Python function named “flexible calculator’ that accepts geraasnyy
arbitrary positional arguments for operands and a keyword argument
‘operation’ for specifying the mathematical operation.
Input: Output:
flexible_caleulator(8,2,operationadd’) Addition Resul
flexible_calculator(8,2,operation= subtract’) Subtraction Resul
flexible calculator(8,2,operation='multiply’) Multiplication Result:16
flexible_calculator(8,2,operation= ‘divide’) Division Result: 4.0
b) Write a Python program using functions to determine whether two input
strings are anagrams. Two words are considered anagrams if the letters of
cone word can be rearranged to form the other word, ignoring spaces and
considering letter case, Note: Don't use any pre-define function,
Input ut
Enter the first string: Tea Tea and Eat are anagrams.
Enter the second string: Eat
Enter the first string: Hello Hello and World are not
Enter the second string: World anagrams.
4, 2), You are tasked with developing a Python program that processes a text (g47-1sm
file (example.txt) containing multiple lines of dala. The goal is to extract
specific information from the file based on user input. Implement the
following functionalities:
L Display the no of characters, now of words and number of lines in the
text file
2.To count the number of upper-case alphabets present in a text file.
3.Display the first 100 characters of the text file, next display the current
position of the file pointer, and print the entire content of the text file.
4.Count the words “to” and “the” present in a text file.
b) You are developing a data processing application that involves handling
a text file named "PYTHON.TXT," which contains a mix of alphanumeric
characters, Your goal is to filter out the numeric digits from the content and
store the modified text in another file named "PYTHONI.TXT." (Note:
Don't use any pre-define function).
Q.No. | Module Number | CO Mapped PSO Mapped
Mapped _| Mapped
a = 3 723456 5 =
@ 3 5 123456 | - -
3 3,6 56 | 123456 E =
[os 6 6 1234.56 = zApply Knowledge. Improve Life!”
QUESTION PAPER
: FALL 2023-2024 — FAT.
Course Code: CSE1012
roblem Sojving using Python
Set number: DetsotEuame HON OOH C FN) CA)
Duration: 120 mins ‘Total Marks: 60
Instructions:
1. Assume data wherever necessary.
2. Any assumptions made should be clearly stated.
[A Alistis said to a lucky collection iit contains odd count of prime numbers. Cree alist (@.7_asnqy
Qt. fn elements at runtime and find whether the curent list is lucky of no.
Sample input
Enter thelist size m:$
Enter the elements fr thelist:
2
3
6
1
8
Sample output:
‘The given listis hicky collection.
1B, Write a python program o create alist of n integer elements, The elements forthe list re
aided during rintime, Ad also check each element in the list is odd or even. Then ereate 2
ictionary with given elements as Keys and their ‘even’ or ‘odd labels as values forthe
sictionary and print the resultant dictionary, Write a complete program to implement above
Semple input
Enter the lst size m: 5
Enter the elements for the ist
10
15
8
4
3
Sample output:
(10: “even’, 15: ‘odd’, 8: ‘even’, 4: ‘even’, 3: ‘odd")
Mr. Ratnesh isthe General Manager of BCCI Bank. He wants to generate the Customer Id
22. for his customer in simple manne, 80 he decided to make customer id as the reverse ofthe 1™)
piven account umber. Define the’ recursive fonction with the name
generate_customet id{eccownt_no), and write the complete program to generate the
Customer id using recursion. And also explain the working flow behind the recursive cal
Sample input:
Enter the account mumber: 123456
Sample output:
Customer id of account number 123456 is 654321
(Mr. Been wants to outsource his code to his subordinates in order to reuse for their further
Q. implementation. He decided to create the module with the name number ase
thmaticpy. In
this module he decided to create four functions without any predefined function suppor. The
details of the functions are given below,_min(list_marabers) —retur the minimurn mumaber in given Tist
‘max(list_mumbers)- return the maximum number in given list
‘sum(list_numbers) - return the sum ofall numbers in given list
Mr. john is a one of the subordinates wants to reuse the functions defined in
snomber_erithmatic module 1o implement his logic. He wants to receive the lst of n integers
from the user and he planned to find the minimum, maximum and sum of integers in the ist.
‘Wiiter the necessary loge o create the mentioned module and implement the given scenario,
Sample input:
Enter the length of the list : 6
Enter the elements tothe list:
44564453
Sample output
‘Minimum number in the lists 3
‘Maximum number in the list is 45
‘Sum of the numbers in the list is 107
‘Note: don’t use any predefined functions to implement min, max and sum methods.
Write « python program to create a file with name customertxt with the following content
Customer name amount spent
Rokith 1500
Ramu 3045
Mohith kumar 5045
Reugarajan 4580
‘And also write the logic to find and print how many customer details are available in the
fiven file, the maximum, minimum and total amount spent by customers in the given file.
omy
‘Sample input:
Enter the file name to create and vite the customer details: customer..xt
Semple output:
Maximum amount spent by the customer is S04S
Minimum amount spent by the eustomer is 1500
‘otal amount spent by all the customer is 14170
(95, _ Write aprtton program o check given peson is ncy or no. The persons sai ey if
both the sum of te digits in date of birth and sum of ascii value of all the alphabets in his
tame are odd umber. Get the person's name and his DOB at runtime and find the given
person is lucky or no
(tom)
‘Sample input:
Enter the person's name |: RAJA
Enter the person's DOB: 12/01/1991
‘Sample output:
Som of digits in DOB is 24 and sum of asi value of al the alphabets in name is 286
‘The person is not Iucky person,
‘Note: if dob is 12/01/1991, then process
orsars
Gane [Moaue umber [contac | 47, | P22, [so mane | mane
Qa 23 23 - = 7=15
@ 3 3 = = 10
ory 5 3 = = B |
eps z ew
eis 3 paGe» VIT-AP
See: UNIVERSITY
Apply Knowledge. Improve Life!”
QUESTION PAPER
Name of the Examination: FALL 2023-2024 — FAT
Course Tite: Problem Solin uslag Python
Duteottsam: ©3)02)00 > (Pd) Cha)
Duration: 120 mins “otal Mars: 60
Instruc
1. Assume data wherever necessary.
2. Any assumptions made should be clearly stated
QI. G@ Take a positive integer as user input and compute its fuctors and (8+7=15M)
display them,
‘Sample input: 12
Output: 1, 2, 3,4, 6, 12
(b) Write a program that takes a nested list of numbers, Then find the
‘minimum number in it.
‘Sample input: L =[1, [-5, 9, 0}, 4, (3, -7, 5, 8], 2]
Output: -7
Q2. (a) Write a function that takes a string and creates another string (748=1SM)
substituting each character of the original string with the character
immediately before it.
‘Sample input: “all is well”
Output: “zk hr vdkk”
(b) Write a function that takes a List of integers and retums True if the
absolute difference between each adjacent pair of elements strictly
increases. Otherwise return False.
‘Sample input: L = [3,4,7,11,17]
Output: True
Q3. (a) Write a program that takes a string and counts the total number of (8+7=15M)
‘words and also finds the longest word.
Sample input: “Python is simple but powerful”
Output: Total no. of words = 5, longest word: powerful
(b) Write @ program that reads a txt file and writes a new file
containing lines in reversed order using string manipulation. (ie.
the first line in the original file becomes the last line in the new
file.)(@) Write a function that takes a square matrix of numbers as input and (8+7=15M)
returns the following two values: Sum of the elements in the
leading diagonal and the sum of the elements in the lagging
diagonal.
1 2)
‘Sample input B |
‘Output: 6, 5
(b) Write a program that takes a decimal number as input and converts
it into its corresponding binary number using strings.
Sample input: 11
Output: 1011
or MAPPING
.No. | Module Number | CO Mapped Marks
a 34 34 [123456[ - : FS
@ 5 5 [asase| = ~_ [Paeis
@ 6 © |iasas6] = = [eis
Cry 5,6 5,6 /123456 . - | s7=I5Gs VIT-AP
=: UNIVERSITY
Apply Knowledge. Improve Life!”
QUESTION PAPER
‘Name of the Examination: FALL, 2023-2024 ~ FAT
Course Code: CSE1012 ane se a
Set mumber: Dateot am: 3/]0/) 20214 CAA) CD,
Duration: 120m tainsanto lad COLD)
Instructions:
1, Assume data wherever necessary.
2. Any assumptions made should be clearly stated.
Qt. @ Write» python program to calculate and print the electricity bill ofa given customer,
* "The customer ID, name, and unit consumed by the user should be eaptured from the
keyboard to display the total amount to be paid to the customer.
‘The charge is as follow: im
init _ [Charge/unit
199 (@1.20
200 and above but less than 400|@1.50_
{400 and above but less than 600)(@1.80
[600 and above [@2.00_
If bill exceeds Rs. 400 then a surcharge of 15% will be charged and the minimum bill
should be of Rs. 100/-
‘Sample Outp
Enter customer ID: 123
Enter customer name: ram
Enter units consumed: 200
(8+7=15M)
Electricity Bill
(Customer ID: 123
Customer Name: ram
Units Consumed: 200
Total Bill Amount: Rs. 300.0
(b) Design a Python program to print duplicates from a list of integers without using
in-built functions,
Sample Outpt
Input: (1,2, 3,2, 3, 4,5,5]
Output: [2,3,'5](@) The Harrison Group Life Insurance company computes annual policy premiums
based on the age the customer tums in the current calendar year. The premium is
computed by taking the decade of the customer’s age, adding 15 toi, and multiplying by
20, For example, a 34-year-old would pay $360, which is calculated by adding the
decades (3) to 15, and then multiplying by 20. Write an application that prompts a user
for the current year and a birth year, Pass both to a function
calculate (current_year,birth_year) that calculates and retums the premium amount,
and then print the retuned amount
Sample Output:
Enter the current year: 2024
Enter the birth year: 1998
‘The premium amount for a 26-year-old is: $340
Q. (8+7=15M)
(b) Python program that generates a random number between 1 and 10 and then prints its
Fibonacci series using recursion
Sample Output:
Generated Random Number: 9
Fibonacci series for 9: 01123581321
3, Create a module named fuctoriahpy with one function fact () with mumber 8.7 1syyy
"parameter and returns the factorial of that number. Create @ separate Python program *
(eg, calculate_factorials.py) to use the factorial.py module to calculate and print
the factorials of the numbers in the given list.
Sample Output:
Original lst: (2, 3, 5, 6]
Factorial list: [2, 6, 120, 720]
() Python program that takes a string input, removes digits and special symbols, and
prints the result
Sample Input
Hello123! How are you?
Sample Output
Hello How are you
a4. (#), Develop a Python program to apply the folowing operations
i. Create a new file named simple. txt and write any three lines of data
ii, Read and print the first two lines
iii, Read and print the last line only
iv. Set the file pointer position after 3 characters from the beginning and print the
contents of that file.
() Develop a python code to open a file faculty.esv and implement the following
i) Write any four faculties’ details including Id, Name, Mobileno and
Email.
ii) Read and prin the faculty details
OR MAPPING
we | Made Number | cOmtepped| 9920.4 | yP2,| 0 Mapped | Marks
Qa 24 | 24 1,2,3,4,5,6 = = S715,
a 5 5 T23a56| - = BIS
@ | 56 56 123,456 = - 8
a 6 6 T23456| ~ =Qu.
Q.
a VIT-AP
» UNIVERSITY
‘Apply Knowledge. Iniprove Life!”
QUESTION PAPER
‘Name of the Examination: FALL 2023-2024 — FAT
Course Code: CSE1012 Course Title: Problem solving using Python
Set numbers J Date of Exam: 29) ox)pe24 (Fis) (By)
oration; 120mins Total Mark: 60
Instructions:
1. Assume data wherever necessary.
2. Any assumptions made should be clearly stated.
8) Develop 2 python Script to print the following given pattern using loops concept In this quyaagnq)
program, input should be taken from the user and the output should be displayed as below.
Output:
A
AB
ABC
ABCD
ABCDE
’) Imagine you are working for a retail company, and you need to analyse the sales performance
of different products across various stores, The company has data in the form of matrices where
cach row represents a store, and each column represents a product. The result ofthe multiplication
will provide insights into the overall sales performance of each store for every product. The
program should use NumPy to perform matrix multiplication, The matrices represent sales data,
Where rows correspond to different stores and columns represent different produets. The result of
{he multiplication will provide insights into the overall sales performance of each store for every
product.
Sample Input: Sample Input: Sample Output:
Sales Data Matrix: Product Price Matrix: Result of Matrix
{{50 30 20} 1213] Multiplication (Sales
[4025 35) (421) Performance):
[60 2025), 132 {{270 160 215}
[265 135 200),
[270 160 235])
4) Consider a scenario where you are working on an inventory management system for @ (7ygaagnq)
‘manufacturing facility. As part ofthe system, you need to calculate the total number of possible
‘ways to arrange a set of identical products on a shelf. Each shelf can accommodate a specific
number of products, and you want to find the total arrangements possible. In this context, you
decide to utilizes recursion to find the factorial of the number of products. This factorial value
represents the total arrangements possible on the shelf, Develop a python script which resembles
above scenario.
Sample Input
Enter the number of identical Products : 5
Sample output:
‘The total arrangements of 5 identical products on the shelf is 120.
) Imagine you are developing a simple program for a coffee shop. Your program needs to
‘manage the orders and calculate the total cost based on the items selected by the customers. The
program should use branching (if statements) to handle different menu options and looping to
allow multiple ordersQ3.
Note: you need to use functions concept for this question.
Sample Input ‘Sample Output:
Welcome to the Coffee Shop Order Management Total cost of your order: $8.00
System
Menu:
1, Espresso - $2.50
2. Latte - $3.50
3. Cappuccino - $3.00
4, Muffin - $2.00
5. Exit
Enter your order (separate items with commas): 1,2,4
a) Develop a python script where you need to create a customized module named as mul which
provides multiplication functionality. After creating a module use that mul module into another ©*7-1S™)
application where you need to develop a code for the multiplication of math tables up to the user
sven input.
‘Sample Input: Sample Output:
Enter the number for the multiplication table: 3 Multiplication Table for 3 up to 2:
Enter the limit for the multiplication table: 2. 3x 1=3
3x26
) Suppose you're developing a text processing application, and one of the requirements is to
cteate a Python function that checks ia specific word or phrase is present in a given paragraph.
How would you design this function to make it case-insensitive, allowing for a more flexible and
user-friendly search functionality? Consider a sample paragraph and word/phrase to demonstrate
the use of your function, Develop a python script forthe above scenatio.
Sample Input:
Enter the Paragraph: "Python is a versatile programming language. Its widely used for various
applications.”
Search Word: "Versatile"
Sample Output:
1s Versatile’ present inthe paragraph? True
2) Develop a Python Script that acceps the string ftom the ser and redisplays the same sting (guaigyq)
afler removing vowels from the given input.
Sample Output:
Enter a string: The food is very tasty
‘The string without vowels is Th fd s vry tsty
b) Develop a python script that writes data toa fle in such a way that each character after a full
stop is to be capitalized and all numbers are written in brackets.
Sample Input:
this isa sample text, it contains some numbers like 123 and 456. let's process it.
Sample Output:
this isa sample text. It contains some numbers like (1][2J[3] and [4][5](6]. Let's process it
QP MAPPING
No. | Module Number | CO Mapped | ayinrea | Mapped | PSO Mapped | Marks
a 34 34 [123456] — - 715
@ 3 35 (| tas4se| = TRIS
a 36 56 [taaase| =
@ 6 6 123436| > 5 wsG VIT-AP
Qe aarvenerry
Sas: UNIVERSITY
Apply Knovstedge. Improve Life!"
QUESTION PAPER
Name of the Examination: FALL 2023-2024 -FAT
Course Code: CSE1012 Course Title: Problem Solving using Python
Set number: & Date ott: 34 /0)] 9024 CEN) (Bp)
Duration: 120 mins ‘Total Marks: 60
Instructions:
1, Assume data wherever necessary.
2. Any assumptions made should be clearly stated,
Given the fst numbers ~[3, 8, 5,2, 9, 4,7, 6,1, 10) implement for Top o tert hough (yp)
‘he ‘numbers' ist and print each element. Use the ‘break’ statement to exit the oop ifan even
‘number is encountered. Use the ‘continue’ statement to skip printing the number 7, Use the
‘pass statement to handle the iteration without any specific action when the number 4 is
encountered,
a.
qx, Yowsre developing a cketing sytem fora theme park where the total number of visitors agyq)
“and the capacities ofthe rides are user-defined. Using Python, implement a program that
assigns visitors to rides based on the provided capacities, Utilize a combination of for and
‘hile loops to distribute visitors, ensuring no ride exceeds its capacity, Print the ride number
and the assigned visitors during the inital assignment using a for loop, then use a while loop
to handle any remaining visitors,
Sample Input:
Enter the total number of visitors: 3
Enter the ride capacities: 2
Sample Output:
Ride 1:2 visitors assigned,
Ride 2:1 visitors assigned,
(@) Design a Fuel Transaction Management System in Python for a fuel station, Write #
3. function named initialize fuel_inventory() that initializes a dictionary representing the
initial fuel inventory for three types of fuel: petrol, diesel, and natural gas. Assume initial
quantities of 10,000 litres for petrol, 8,000 litres for diese, and 5,000 lites for natural gas,
with corresponding prices perlite of Rs. 80.0, Rs. 70.0, and Rs. 50.0, respectively. Create a
function called record_fuel_transaetion(inventory) that takes user inputs for fuel type,
quantity, and vehicle registration number, Ensure error handling for invalid inputs,
insufficient stock, and negative quantities. Update the inventory based on the recorded
transaction and print the tion amount, Writs 2 function named
transaction report(inyentory, initial inventory) that calculates and prints the total
revenue for the day and the number of transactions foreach fuel type
Sample Input / Output
“Enter the fuel type (petroV/dieseUnatural_gas): petrol
Enter the quantity of fuel: 2
‘Transaction revorded successfully. Amount: Rs. 160,00
Enter the fuel type (petrol/dieselinatural_gas): diesel
Enter the quantity of fuel: 4
‘Transaction recorded successfully. Amount: Rs, 280,00
(1248+ 20M)
Daily Transaction Report
Total Revenue for the Day: Rs, 440,00
Petrol Transactions: 2
Diesel Transactions: 4
Natural_gas Transactions: 0() You are developing a Python program for a faculty member who is managing a set of |
courses. Write a Python program function that replicates the faculty member guiding courses
recursively. The funetion should print the statement "Teaching [course] for each course in the
list,
‘Sample Input
Enter the list of courses (comma-separated): 0S, DBMS, CN, DAA
Sample Output:
‘Teaching OS.
‘Teaching DBMS
Teaching CN
‘Teaching DAA
() Develop a Python programn for an advanced student records management system Using 194450
file handling. Implement a function that allows users to input and add new student records, @10+18-25M)
including details such as name, registration number, course, end grade. The program should
append the new records tothe file named “student fecords txt". Create a function that reads
and displays the existing student records,
Sample Input/Output:
Enter student name: Roy
Enter registration number: 21bee0001
Enter course: CN
Enter grade: A
Student record added successfully.
Enter student name: ABC
Enter registration number: 21 MMMO000
Enter course: OS
Enter grade: A
Student record added successfully
[Existing Student Records
Name: Roy, Registration Number: 21beo0001, Course: CN, Grade: A
‘Name: ABC, Registration Number: 21MMMO000, Course: OS, Grade: A
() Consider the given data are stored in a CSY file named employee_data.csv
Name, Company, Salary
Roy, ABC Corp, 60000
Smith, XYZ Ltd, 75000
Bob, [MN Ine, $0000
Alice, PQR Co, 80000
Charlie, IKL Enterprises, 70000
Write a Python program to read the data from the CSV file and display the details of
‘employees who have a salary greater than or equal to 70,000, Print the name, company, and
salary for each qualifying employee. Implement a function that takes input for a new
employee's name, company, and salary, and appends this information to the existing CSV.
file. After adding the new employee, calculate and print the average salary of all employees
inthe dataset.
OP MAPPING
QNo, | Module Number |CO Mapped | yclnbeq | mappea | PSO Mapped | Marks
a 34 34 [tease : 5
@ 3 a 123456 [= = i
eS 3 3 123456 [|= = 1258-20
e 6 6 Ta3Asep dt TOrIs25=
4 CFA) CC)
Duration: 120 mins Total Marks: 60
Instructions:
1. Assume data wherever necessary.
2. Any assumptions made should be clearly stated.
a.
Q.
Create a Python program that will determine the eligibility ofa student for a (4 5y9)
scholarship based on their academic performance. The program should take
the student's average grade as input and determine the scholarship amount
based on the following criteria:
@) A student who has an average grade of 90 or higher is eligible for a full
scholarship (100%).
b) If the average grade is between 80 and 89 (inclusive), the student is
eligible for a half scholarship (50%).
©) If the average grade is between 70 and 79 (inclusive), the student is
eligible for a quarter scholarship (25%).
d) If the average grade is below 70, the student is not eligible for any
scholarship.
Write the Python program and provide a flowchart to visually represent the
decision-making process.
Using Python, write a program to manage a bookstore's inventory. Each book sq)
tuple contains its title, author, price, and quantity available. Define a function
caleulate total_value that calculates and returns the total value of the
bookstore’s inventory, considering the price and quantity of each book. Add a
function most_expensive_book that returns the authors and titles of the most
expensive books in an inventory given a list of book tuples. Create a third
function update_inventory that takes the list of book tuples and updates the
quantity of a specific book based on the user's input.
Sample Input: book_inventory = [("Introduction to Python", "John Smith’,
25.99, 50), ("Data S
nce Basics", "Alice Johnson", 34.50, 30), ("Advanced
Algorithms", "Bob Williams", 45.75, 20), ]
Sample output:
1
2.
3. Updated inventory: Quantity of “Introduction to Python is” is reduced
‘The total value of the bookstore's inventory is $4347.25.
The most expensive book is “Advanced Algorithms” by Bob Williams.
to453, Write « Python function generate_permutations that takes a string as input (549)
* and returns a list of all possible permutations of the characters in the string
using recursion. No predefined functions are allowed.
Sample input and output
Permutations of ‘abe: ['abe’,'acb’,"bac’,‘bca’, ‘cab, cba’)
Q4, Wate a Python program that manages a simple student database using file (45yq)
“handling. The student information includes their name, age, and grade. Create
a function Add_student takes student information (name, age, grade) as
‘input, appends it toa file named "student_database.txt," and returns a success
message.
. Create another function read_student_database that reads the contents
of "student_database.txt" and prints out student information.
b. Create a third function update_student_grade that updates the grade in
the “student _database.txt” and retums a success message.
OP MAPPING
0.No, | Module Number | COMtapped | 4922.4 | 780, | ws0 Mapped | Maris
[a 2 23 123456| - * is
@ 5 3 plasasey 5
@ 5.6 5 | 123456 - | * 1s
Qt 6 4 1,2,3,4,5,6 a = 1s“» VIT-AP
UNIVERSITY
‘Apply Knowledge. Improve Life!”
QUESTION PAPER
‘Name of the Examination: FALL 2023-2024 - FAT
Course Code: CSE1012 Course Title: Problem Solving using Python
Setoumber: 9 Date oftxam: 91 0//y004 CAN) Aa)
Duration; 120 mins “Total Marks: 60
Instructions:
1. Assume data wherever necessary,
2. Any assumptions made should be clearly stated.
Qu, The following requirements should be met by a Python program: Initialize
the savings account balance to 1000. The user is presented with a menu with
the following options using a while loop: "D" is for depositing money into
the account. "W" is for withdrawing money from the account. "Q" is for
‘quitting the program. Limit the number of transactions to a predefined value
(uch as 5), If the user withdraws more money than is available in the
account, display an error message and do not process the withdrawal
Sample Input/Output:
Welcome to the savings Account!
Current Balance: $1000
Transaction 1: Enter "D" to deposit, "W" to withdraw, or "Q" to quit: D
Enter the deposit amount: 200
Current Balance: $1200
‘Transaction 2: Enter "D" to deposit, "W" to
Enter the withdrawal amount: 500
Current Balance: $700
‘Transaction 3: Enter "D" to deposit, "W" to withdraw, or "Q" to quit: D
Enter the deposit amount: 300
Current Balance: $1000
draw, ot "Q" to quit: W
Create a library system that allows users to borrow and return books, as well
a5 maintain a calalog of available books. Develop a Python program that
‘manages library operations using nested functions. Create a Python program
that satisfies the following requirements: Initialize a list to represent a library
catalog. Display the current list of available books using a function named as
display_catalog(). Define a function borrow_book() that allows a user to
borrow a book. If the book is available, remove it from the catalog. If the
book is not available, display an error message. Define a function
return_book() that allows a user to return a book. If the book is not in the
catalog, add it back. If the book is already in the catalog, display an error
message.
(asm)
(asm)Q3.
Sample Output: Current Library Catalog:
1. Python Programming Output: Borrowing “Python
programming”
2. Data Science Essentials Book successfully burrowed
Create a program that reverses a given string through recursion, Define & (sq)
function reverse_string_recursive() that takes a string as input and returns
the reversed string, Use recursion to reverse the string characters. Display the
results. No predefined methods should be used in the program.
‘Sample Input: Recursion is fun!
Sample Output: Inuf si noisruceR.
Implement a Python program that uses file handling with CSV files to add
employee records, display existing records, and calculate the average salary
for all employees. Create a CSV file named as “employees.csv” and perform
the operations enlisted below:
(asm)
a. Create a function add_employee() that takes employee details (name,
salary) as input and adds a new record to the employees.csv file.
b. Display all the employee records from the "employees.csv" file by
defining a function display_employees().
©. Calculate and retum the average salary of all employees using the
function calewlate_average_salary()
oP MAPPING
@.No. | Module Number | CO Mapped PSO Mapped | Marks
a 2 Ey 2 B
[@ 5 5
@ 36 5
a 6 a 123436 5 5UNIVERSITY
Apply Knowledge. Improve Life!”
QUESTION PAPER
Name of the Examination: FALL 2023-2024 — FAT
Course Code: CSE1012 Course Title: Problem Solving using Python
Set number: {) Dacottsm o9/0/r0%4 (AA) A)
Duration: 120 mins Total Marks: 60
Instructions:
1. Assume data wherever necessary.
2. Any assumptions made should be clearly stated.
8) Fora given value of ‘n' (entered by user), write aprogramusing python o print the
A following pattern: ree)
e
23... .(n-1) 0
) Write a program to create a list of random numbers in range of 1 to 50. Then delete
all numbers divisible by 3 or 4 and print the final lst
Input: Enter the length of the list: 10
Output: The original list is: [1, 3, 4, 25, 45, 12, 33, 38, 40, 12]
‘The final list is: (1, 25, 45, 33, 38]
gz, ® Write a python program using recursion to print factorial ofa given number (5419-1541)
centered by the user.
) A student made the module (file name = My_module.py) with the following,
functions.
‘Module Name Description
My_ADD Ts additon of wo numbers pasted as a gue
My SUB T Finds subiaction of two numbers passed as an argument
My DIV ‘Kinds division of two numbers psied at an argument
iy MOD Tings modulus of two mumbers passed > an argument
My MOL. Tefinds mulipistion of two number pased as an argument
Write the module and using it show how to calculate ad
multiplication and division sf 2 integers entered by the user.
jon, subtraction,
4) Write function (without using split) function) which separates and print domain (9, 6 1544)
‘name from the email ID entered by the user.
Input: Enter an email ID: vtop [email protected]
Output: Domain is: vitap.ac.in
b) A student has written the following code and getting some error: Explain the reason
for this with suitable conceptual reasoning.
Q3.o> def Ada_somn(a,b)?
connie
Print (c)
39> print (c)
fTeaceback (nest recent call tast):
File "apyshellés>",
sane (6)
2, tn emotes
4, 2A faculty created a quiz with 10 questions in a *CAT_Quiztat file as given below
"(Correct option are saved in the next line to the question), Write a python program to
display questions one-by-one, record the response of the candidate, and at last show
the score of the candidate (Assume each question carries 1 mark and there is no
negative marking in the evaluation.).
BE ceca: neged
(10+5= 15M)
2 He As She capt of Inte: A) Now Delht a) Katkate C) oped 0) Negur
{Sn tndtn got Andependance: A) 1965 0) 1966 ©) 38470) 18
. swt 4s formsta OF water: A) a2) OM ©) 520 0) 120
G9. Sam ane fram.o:t A) Hoth 8) South C) West ONEast
») Write program to print the number of times ‘a” i used in a paragraph writen
in txt file
Sample Fil
cme 07
aw) | 4 POI,PO2 | - - 08
@3@ | 5 3 |Por,Po2|- 5 o7
axe) |S 3 [POI,PO4| - : 08
Me) 6 6 _|PO1,PO4| - = 09
em [6 6 [POUPos] - - 06
(o+6-15M),GS VIT-AP
ey
reeeas: UNIVERSITY
‘Apply Knowledge. Improve Life!”
QUESTION PAPER
‘Name of the Examination: FALL 2023-2024 — FAT
csei012 Course Title: Problem solving using Python
Set number: | Dateottsam: 62] 09/2004) (Fis) cA)
Duration: 120mins ‘Total Marks: 60
Instructions:
1, Assume data wherever necessary.
2. Any assumptions made should be clearly stated,
4) Some prime numbers can be expressed as a sum of other consecutive prime eg,
a. numbers. Your task is to find out how many prime numbers that satisfy this *"15M)
property are present in the range 3 to'N subject oa constraint that summation
should always start with number 2. Write a Python program to find out the
number of prime numbers that satisfy the above-mentioned property in a
given range.
Input: N=20
‘Output: 2
Explanation: Below 20, there are 2 such numbers,
5-243, 1722434547
Input: N=45
Output: 3
Explanation: Below 45, there are 3 such numbers,
S243, 17=2434547, 4124345474 11413,
b) VIT-AP Physics Lab has built a GUI for temperature conversion. First, it
takes input data as temperature (lemp). The unit has been set as Kelvin(k) /
Celsius(c) / Fahrenheit(f). In this GUL, conversion of Kelvin(k) / Celsius(c)
‘/Fabrenheit(t) temperature into other temperature units is possible. Write an
algorithm for the temperature conversion using a multiway branching
statement. Temperature Unit and Temperature Data have been taken by the
user as input. The formula for conversion is given below
K=C+273.15
F=C(95)+32
K=(F~32)x 59+273.15
@. Dr. Ram needs to complete the sjllabus for the final exam. He wanted 19 (sy)
: calculate the number of weeks for a given class day as Tuesday and count the
number of Tuesdays within n number of days. Write a Python program for the
given scenario for any month using a function calling function. Define a
function as num_week() where function find_index_of_day(day, days) has
to call for calculating the number of weeks for the given day and N number of.
days.
Input: day~Tuesday Input: day=Thursday
N Neild
Output: 5 weeks Output:2 weeksWrite a Python program to display the modified Fibonacci series using (ggyq)
recursion. Consider, the fist two terms of the series are as user input, the third
term in the series can be found as a subtraction between Ist and 2nd terms.
‘This process will be continued up to the given limit N.
‘Before printing the series check if the limit is valid or not.
If limit is less than equals to 0 then print Invalid
If limit is equal to 1 then print only 1st term
If limit is equal to 2 then print Ist term and 2" term
Else print the series for the limit N.
‘Take limit N as user input
Sample input: ‘Sample output:
and 1
be3 2
N-S 4
2
a
Write a Python program to create a happy password by checking ifthe string (yyqy
contains a contiguous substring of length strictly greater than 2 in which all its
characters are vowels.
Input: password= ace2de@fghi
‘Output: The Password is a happy password
Input: password ak2de@fghi
Output: The Password is not a happy password
Write a Python program to create a file and write operations using file (gyqy
handling, The user takes input as strings (each line) and writes them to a text
file(.txt). Count the number of words present in that text file using file handling
and string manipulation.
ae |e
Enter a line : how are you | (fr tw
Enter a fine: hope you are | 4% yoy
doing well tape ore dng wt
Lines written to output_text.txt
‘Number of words in the file: 10
OF MAFRING
No. | Module Number | CO Mapped | ycrymeg | Mapped |®8O Mapped | Marks
a 23 123 | Tas4se) : HIS
@ 5 3 123456 | 7 i
| @ 5 5 123456 | - = i0
wey 6 o [128456 : @
@ 6 6 |taaase[_- = =]